#include<iostream>
#include<vector>
#include<queue>
#include<fstream>
#include<algorithm>
#include<limits.h>
#include<stack>
using namespace std;
#define ll long long
const long long mod = 1000000007;
ll n, d, m;
vector<ll> arr;
vector<ll> need;
bool ok(ll mid) {
ll done = 0; ll left = 0;
for (int i = 0; i < n; i++) {
done += min(mid, arr[i] + left);
if (mid < arr[i]) left += arr[i] - mid;
done -= need[i];
//cout << i << ' ' << done << '\n';
if (done < 0) {
return false;
}
}
return true;
}
int main() {
cin >> n >> d >> m;
arr.resize(n); need.resize(n);
for (int i = 0; i < m; i++) {
int x; cin >> x; x--;
arr[x]++;
need[x + d]++;
}
ll l = 0; ll r = 1e18;
ll ans = 0;
while (l <= r) {
ll mid = (l + r) / 2;
if (ok(mid)) {
ans = mid;
r = mid - 1;
}
else l = mid + 1;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
716 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
23 ms |
716 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
23 ms |
736 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
23 ms |
692 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
69 ms |
716 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
24 ms |
688 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
24 ms |
740 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
67 ms |
684 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
31 ms |
2096 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
33 ms |
2112 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
44 ms |
660 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
51 ms |
972 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
80 ms |
1428 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
123 ms |
2324 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
136 ms |
2072 KB |
Output isn't correct |
16 |
Incorrect |
187 ms |
2964 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
250 ms |
2968 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
205 ms |
2596 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
244 ms |
3908 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
228 ms |
2972 KB |
Unexpected end of file - int32 expected |