#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
const int M = 1e6 + 1;
int dp[N] , arr[M] , pre[N];
int n,m,d;
bool solve(int mid) {
for(int i=1;i<=n;i++) dp[i] = 0, pre[i] = i;
for(int i=1;i<=m;i++) dp[arr[i]]++;
for(int i=1;i<=m;i++) {
if (dp[i] > mid) {
if ((i+1)-pre[i] > mid) return false;
pre[i+1] = pre[i];
dp[i+1] += dp[i] - mid;
}
}
return dp[m+1]==0;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> m >> d >> n;
for(int i=1;i<=m;i++) cin >> arr[i];
int l = 1 , r = N;
while (l < r) {
int mid = (l + r) / 2;
if (solve(mid)) r = mid;
else l = mid + 1;
}
cout << l;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1108 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
1108 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
1108 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
1152 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
1108 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
1108 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
1108 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
1108 KB |
Output isn't correct |
9 |
Incorrect |
11 ms |
1492 KB |
Output isn't correct |
10 |
Incorrect |
12 ms |
1492 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
12 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
13 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
14 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
15 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
16 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
17 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
18 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
19 |
Runtime error |
8 ms |
1236 KB |
Execution killed with signal 11 |
20 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |