#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
int n,d,p; cin >> n>>d>>p;
map<int, vector<int> > conv;
int jobs[p]; for(int i=0; i<p; i++){cin >> jobs[i]; conv[jobs[i]].push_back(i+1);}
sort(jobs, jobs+p);
int l=1; int r = 1e6;
int ans=-1;
while(l<r){
int m = 2;
int day=0;
int counter=0;
bool check=true;
for(int i=0; i<p; i++){
if(jobs[i] > day){day = jobs[i]; counter=1;}
else{
if(counter==m){
day++;
counter=0;
}
if(day-jobs[i] >d) check=false;
counter++;
}
}
if(check){r=m-1; ans=m;}
else l=m;
}
cout << ans<<endl;
int day=1;
int coun=0;
for(int i=0; i<p; i++){
if(jobs[i]>day){
for(int k=day; k<jobs[i]; k++) cout << 0<<endl;
day = jobs[i];
coun=1;
cout << conv[jobs[i]][0] << " ";
conv[jobs[i]].erase(conv[jobs[i]].begin());
}else{
if(coun == ans){
day++; coun=0; cout << 0 <<endl;
}
cout << conv[jobs[i]][0] << " ";
coun++;
conv[jobs[i]].erase(conv[jobs[i]].begin());
}
}for(int i=day; i<=n; i++) cout << 0 <<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
1580 KB |
Time limit exceeded |
2 |
Execution timed out |
1089 ms |
1580 KB |
Time limit exceeded |
3 |
Execution timed out |
1078 ms |
1616 KB |
Time limit exceeded |
4 |
Execution timed out |
1062 ms |
1616 KB |
Time limit exceeded |
5 |
Execution timed out |
1076 ms |
1608 KB |
Time limit exceeded |
6 |
Execution timed out |
1086 ms |
1616 KB |
Time limit exceeded |
7 |
Execution timed out |
1086 ms |
1616 KB |
Time limit exceeded |
8 |
Execution timed out |
1084 ms |
1596 KB |
Time limit exceeded |
9 |
Execution timed out |
1076 ms |
1544 KB |
Time limit exceeded |
10 |
Execution timed out |
1078 ms |
1516 KB |
Time limit exceeded |
11 |
Execution timed out |
1081 ms |
1620 KB |
Time limit exceeded |
12 |
Execution timed out |
1062 ms |
2892 KB |
Time limit exceeded |
13 |
Execution timed out |
1087 ms |
4832 KB |
Time limit exceeded |
14 |
Execution timed out |
1075 ms |
7372 KB |
Time limit exceeded |
15 |
Execution timed out |
1089 ms |
7192 KB |
Time limit exceeded |
16 |
Execution timed out |
1051 ms |
10540 KB |
Time limit exceeded |
17 |
Execution timed out |
1081 ms |
12564 KB |
Time limit exceeded |
18 |
Execution timed out |
1074 ms |
11028 KB |
Time limit exceeded |
19 |
Execution timed out |
1082 ms |
11672 KB |
Time limit exceeded |
20 |
Execution timed out |
1088 ms |
12604 KB |
Time limit exceeded |