Contest Duration: - (local time) (100 minutes) Back to Home

Submission #16755795

Source Code Expand

Copy
```#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
int N,K; cin >> N >> K;
vector<int> v(N);
REP(i,N) cin >> v[i];

REP(i,N) {
if (v[i] != 1) continue;
// cerr << i << endl;
auto left = i;
auto right = N - i - 1;

auto left_cost = (i+K-1-1)/(K-1);
if (left_cost && (left_cost * (K-1)) > left) right -= (left_cost * (K-1)) - left;

chmax(right,0);
auto right_cost = (right+K-2)/(K-1);
cout << left_cost+right_cost << endl;
}
assert("bugged");
}

int main() {
solve();
return 0;
}```

#### Submission Info

Submission Time 2020-09-15 10:44:14+0900 C - Minimization reud C++ (GCC 9.2.1) 300 1102 Byte AC 33 ms 3748 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
 AC × 3
 AC × 16
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt AC 15 ms 3376 KB
10.txt AC 28 ms 3460 KB
2.txt AC 33 ms 3748 KB
3.txt AC 18 ms 3512 KB
4.txt AC 25 ms 3516 KB
5.txt AC 30 ms 3464 KB
6.txt AC 28 ms 3568 KB
7.txt AC 6 ms 3440 KB
8.txt AC 29 ms 3512 KB
9.txt AC 2 ms 3520 KB
sample1.txt AC 2 ms 3576 KB
sample2.txt AC 2 ms 3436 KB
sample3.txt AC 2 ms 3508 KB