#include <bits/stdc++.h>
using namespace std;
const int M=1e6+12;
int n,d,m;
pair<int,int>a[M];
bool good(int num) {
int i=0;
int day=1;
int cnt=0;
while(i<m){
if(cnt==num){
cnt=0;
day++;
}
if(a[i].first>day){
day=a[i].first;
}
if(a[i].first+d<day){
return false;
}
i++;
cnt++;
}
return day<=n;
}
int main() {
cin>>n>>d>>m;
for(int i=0;i<m;i++){
cin>>a[i].first;
a[i].second=i;
}
sort(a,a+m);
int l=1;
int r=m;
int mid=(l+r)/2;
while(l<r){
mid=(l+r)/2;
if(good(mid)){
r=mid;
}
else{
l=mid+1;
}
}
int cnt=0;
cout<<l<<endl;
int days=1;
for(int i=0;i<m;i++){
if(a[i].first<=days){
cout<<a[i].second+1<<" ";
cnt++;
if(cnt==l){
cout<<0<<endl;
cnt=0;
days++;}}
else{
cout<<0<<endl;
days++;
cnt=0;
}
}
for(int i=days;i<=n;i++){
cout<<0<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
3172 KB |
Output is correct |
2 |
Correct |
34 ms |
3152 KB |
Output is correct |
3 |
Correct |
32 ms |
3160 KB |
Output is correct |
4 |
Correct |
32 ms |
3164 KB |
Output is correct |
5 |
Correct |
33 ms |
3164 KB |
Output is correct |
6 |
Correct |
33 ms |
3156 KB |
Output is correct |
7 |
Correct |
32 ms |
3152 KB |
Output is correct |
8 |
Correct |
32 ms |
3152 KB |
Output is correct |
9 |
Correct |
137 ms |
3408 KB |
Output is correct |
10 |
Correct |
135 ms |
3412 KB |
Output is correct |
11 |
Correct |
34 ms |
3156 KB |
Output is correct |
12 |
Correct |
61 ms |
3920 KB |
Output is correct |
13 |
Correct |
91 ms |
6484 KB |
Output is correct |
14 |
Correct |
147 ms |
7248 KB |
Output is correct |
15 |
Incorrect |
159 ms |
8224 KB |
Output isn't correct |
16 |
Correct |
211 ms |
10832 KB |
Output is correct |
17 |
Correct |
248 ms |
11476 KB |
Output is correct |
18 |
Correct |
260 ms |
12112 KB |
Output is correct |
19 |
Incorrect |
394 ms |
13856 KB |
Output isn't correct |
20 |
Correct |
247 ms |
11344 KB |
Output is correct |