#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int N, D, M;
pair<int,int> jobs[1000005];
bool check(int m){
int maxD = -1;
int j = -1;
for(int i=0;i<N;i++){
int count = 0;
while(count!=m&&j!=M-1&&jobs[j+1].first<=i+1){
maxD = max(maxD,i+1-jobs[++j].first);
count++;
}
}
if(maxD > D) return true;
return false;
}
int search(){
int ans = 0;
for(int val = M; val >= 1; val /= 2){
while(ans+val <= M && check(ans+val)) ans += val;
}
return ans + 1;
}
int main(){
cin >> N >> D >> M;
for(int i=0;i<M;i++){
cin >> jobs[i].first;
jobs[i].second = i+1;
}
sort(jobs,jobs+M);
int minM = search();
cout << minM << "\n";
int j = -1;
for(int i=0;i<N;i++){
int count = 0;
while(count!=minM&&j!=M-1&&jobs[j+1].first<=i+1){
cout << jobs[++j].second << " ";
count++;
}
cout << "0\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
1600 KB |
Output is correct |
2 |
Correct |
30 ms |
1624 KB |
Output is correct |
3 |
Correct |
32 ms |
1600 KB |
Output is correct |
4 |
Correct |
29 ms |
1612 KB |
Output is correct |
5 |
Correct |
32 ms |
1592 KB |
Output is correct |
6 |
Correct |
29 ms |
1612 KB |
Output is correct |
7 |
Correct |
29 ms |
1620 KB |
Output is correct |
8 |
Correct |
28 ms |
1580 KB |
Output is correct |
9 |
Correct |
40 ms |
1740 KB |
Output is correct |
10 |
Correct |
42 ms |
1876 KB |
Output is correct |
11 |
Correct |
39 ms |
1592 KB |
Output is correct |
12 |
Correct |
76 ms |
3148 KB |
Output is correct |
13 |
Correct |
129 ms |
4640 KB |
Output is correct |
14 |
Correct |
177 ms |
6100 KB |
Output is correct |
15 |
Correct |
198 ms |
7508 KB |
Output is correct |
16 |
Correct |
256 ms |
9168 KB |
Output is correct |
17 |
Correct |
324 ms |
10488 KB |
Output is correct |
18 |
Correct |
312 ms |
12072 KB |
Output is correct |
19 |
Correct |
365 ms |
13900 KB |
Output is correct |
20 |
Correct |
302 ms |
10572 KB |
Output is correct |