#include<bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
using namespace std;
ll i,n,d,m,l,r,mid;
pair<ll,ll> a[1000005];
bool check(ll mid){
ll i,j,day=0;
for(i=1;i<=m;){
day++;
for(j=i;j<i+mid && j<=m;j++){
if(a[j].ff<day) break;
if(day>a[j].ff+d) return 0;
}
i=j+1;
}
if(day>n) return 0;
return 1;
}
int main(){
cin >> n >> d >> m;
for(i=1;i<=m;i++){
cin >> a[i].ff;
a[i].ss=i;
}
sort(a+1,a+m+1);
l=1;
r=m;
while(r-l>1){
mid=(r+l+1)/2;
if(check(mid)) r=mid;
else l=mid;
}
if(check(l)) cout << l;
else cout << r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
2904 KB |
Output isn't correct |
2 |
Incorrect |
15 ms |
2908 KB |
Output isn't correct |
3 |
Incorrect |
15 ms |
2908 KB |
Output isn't correct |
4 |
Incorrect |
15 ms |
2904 KB |
Output isn't correct |
5 |
Incorrect |
16 ms |
2908 KB |
Output isn't correct |
6 |
Incorrect |
16 ms |
2904 KB |
Output isn't correct |
7 |
Incorrect |
15 ms |
2904 KB |
Output isn't correct |
8 |
Incorrect |
16 ms |
2908 KB |
Output isn't correct |
9 |
Incorrect |
22 ms |
2924 KB |
Output isn't correct |
10 |
Incorrect |
22 ms |
2908 KB |
Output isn't correct |
11 |
Incorrect |
24 ms |
2908 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
48 ms |
5484 KB |
Output isn't correct |
13 |
Incorrect |
77 ms |
7888 KB |
Output isn't correct |
14 |
Incorrect |
109 ms |
8532 KB |
Output isn't correct |
15 |
Incorrect |
120 ms |
10576 KB |
Output isn't correct |
16 |
Incorrect |
164 ms |
13904 KB |
Output isn't correct |
17 |
Incorrect |
191 ms |
16204 KB |
Output isn't correct |
18 |
Incorrect |
201 ms |
18012 KB |
Output isn't correct |
19 |
Incorrect |
225 ms |
18256 KB |
Output isn't correct |
20 |
Incorrect |
191 ms |
16216 KB |
Output isn't correct |