#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
using pii = pair<ll , ll> ;
using i3 = tuple<ll , ll , ll> ;
const int N = 1e5+5 ;
const int MOD = 1e9+7 ;
ll n , d , m ;
pii S[N] ;
bool solve(ll mid){
ll day = 1 , cnt = 0 ;
for(int i=1;i<=m;i++){
if(day < S[i].first){
day = S[i].first ;
cnt = 0 ;
}
if(cnt == mid){
day++;
cnt = 0 ;
}
if(day > S[i].first + d){
return false ;
}
cnt++;
}
if(day > n) return false ;
return true ;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> d >> m ;
for(int i=1, x;i<=m;i++){
cin >> x ;
S[i] = {x , i};
}
sort(S+1 , S+m+1) ;
ll l = 1 , r = m , ans = 0 ;
while(l <= r){
ll mid = (l+r)/2 ;
if(solve(mid)){
r = mid-1 ;
ans = mid ;
}
else {
l = mid+1 ;
}
}
cout << ans << "\n" ;
for(int i=1;i<=n;i++){
cout << "0\n" ;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
2136 KB |
Output is correct |
2 |
Correct |
12 ms |
2152 KB |
Output is correct |
3 |
Correct |
15 ms |
2132 KB |
Output is correct |
4 |
Correct |
12 ms |
2132 KB |
Output is correct |
5 |
Correct |
12 ms |
2076 KB |
Output is correct |
6 |
Correct |
12 ms |
2120 KB |
Output is correct |
7 |
Correct |
12 ms |
2132 KB |
Output is correct |
8 |
Correct |
12 ms |
2140 KB |
Output is correct |
9 |
Correct |
23 ms |
2252 KB |
Output is correct |
10 |
Correct |
28 ms |
2232 KB |
Output is correct |
11 |
Correct |
27 ms |
2132 KB |
Output is correct |
12 |
Incorrect |
8 ms |
2132 KB |
Output isn't correct |
13 |
Incorrect |
8 ms |
2076 KB |
Output isn't correct |
14 |
Incorrect |
14 ms |
2164 KB |
Output isn't correct |
15 |
Incorrect |
11 ms |
2172 KB |
Output isn't correct |
16 |
Incorrect |
13 ms |
2124 KB |
Output isn't correct |
17 |
Incorrect |
11 ms |
2132 KB |
Output isn't correct |
18 |
Incorrect |
8 ms |
2072 KB |
Output isn't correct |
19 |
Incorrect |
8 ms |
2132 KB |
Output isn't correct |
20 |
Incorrect |
12 ms |
2212 KB |
Output isn't correct |