#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;
for(int i=1;i<=n;i++){
int p=mid;
while(j<m and p>0){
if(v[j].ff > i+d)break;
j++;
p--;
}
}
return j==m;
}
void fun(int mid){
int j=0;
for(int i=1;i<=n;i++){
int p=mid;
while(j<m and p>0){
if(v[j].ff > i+d)break;
cout<<v[j].ss<<" ";
j++;
p--;
}
cout<<0<<endl;
}
}
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=1e9;
while(hi>=lo){
int mid=(hi+lo)/2;
bool u=check(mid);
if(u){
hi=mid-1;
}
else{
lo=mid+1;
}
}
cout<<lo+1<<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
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
3524 KB |
Output isn't correct |
2 |
Incorrect |
32 ms |
3524 KB |
Output isn't correct |
3 |
Incorrect |
32 ms |
3524 KB |
Output isn't correct |
4 |
Incorrect |
31 ms |
3512 KB |
Output isn't correct |
5 |
Incorrect |
31 ms |
3640 KB |
Output isn't correct |
6 |
Incorrect |
32 ms |
2500 KB |
Output isn't correct |
7 |
Incorrect |
33 ms |
2500 KB |
Output isn't correct |
8 |
Incorrect |
31 ms |
2500 KB |
Output isn't correct |
9 |
Incorrect |
159 ms |
2500 KB |
Output isn't correct |
10 |
Incorrect |
164 ms |
2500 KB |
Output isn't correct |
11 |
Correct |
26 ms |
2500 KB |
Output is correct |
12 |
Incorrect |
53 ms |
4536 KB |
Output isn't correct |
13 |
Correct |
82 ms |
8628 KB |
Output is correct |
14 |
Incorrect |
124 ms |
8632 KB |
Output isn't correct |
15 |
Correct |
122 ms |
8628 KB |
Output is correct |
16 |
Correct |
175 ms |
16800 KB |
Output is correct |
17 |
Correct |
224 ms |
16920 KB |
Output is correct |
18 |
Incorrect |
217 ms |
16816 KB |
Output isn't correct |
19 |
Incorrect |
366 ms |
16976 KB |
Output isn't correct |
20 |
Correct |
219 ms |
16796 KB |
Output is correct |