#include<bits/stdc++.h>
using namespace std;
#define itn long long
#define ff first
#define ss second
#define int long long
#define pb push_back
vector<pair<int,int>>v;
int n,d,m;
bool check(int mid){
int j=0;
bool u=1;
for(int i=1;i<=n;i++){
int p=mid;
while(j<=m){
if(p==0 or v[j].ff>i){
break;
}
if(i<=v[j].ff+d){
p--;
j++;
}
else{
u=0;
break;
}
}
}
return (u & (j==m));
}
signed main(){
cin>>n>>d>>m;
for(int i=1;i<=m;i++){
int x;
cin>>x;
v.pb({x,i});
}
sort(v.begin(),v.end());
int lo=0,hi=1e16;
while(hi>=lo){
int mid=(hi+lo)/2;
bool u=check(mid);
if(u==0){
lo=mid+1;
}
else{
hi=mid-1;
}
}
cout<<lo<<endl;
for(int i=1;i<=n;i++)cout<<0<<endl;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
34 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
2 |
Incorrect |
36 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
3 |
Incorrect |
34 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
4 |
Incorrect |
43 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
5 |
Incorrect |
36 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
6 |
Incorrect |
40 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
7 |
Incorrect |
40 ms |
2504 KB |
Expected int32, but "10000000000000001" found |
8 |
Incorrect |
33 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
9 |
Incorrect |
176 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
10 |
Incorrect |
173 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
11 |
Incorrect |
29 ms |
2500 KB |
Expected int32, but "10000000000000001" found |
12 |
Incorrect |
67 ms |
4608 KB |
Expected int32, but "10000000000000001" found |
13 |
Incorrect |
83 ms |
8628 KB |
Expected int32, but "10000000000000001" found |
14 |
Incorrect |
135 ms |
8636 KB |
Expected int32, but "10000000000000001" found |
15 |
Incorrect |
135 ms |
8716 KB |
Expected int32, but "10000000000000001" found |
16 |
Incorrect |
196 ms |
16896 KB |
Expected int32, but "10000000000000001" found |
17 |
Incorrect |
225 ms |
16796 KB |
Expected int32, but "10000000000000001" found |
18 |
Incorrect |
237 ms |
16808 KB |
Expected int32, but "10000000000000001" found |
19 |
Incorrect |
404 ms |
16888 KB |
Expected int32, but "10000000000000001" found |
20 |
Incorrect |
225 ms |
16796 KB |
Expected int32, but "10000000000000001" found |