#include<bits/stdc++.h>
using namespace std;
#define MAX (long long)(1e6) + 10
pair<int, int> v[MAX];
int n, d, m;
bool f(int k){
int p=1;
for(int i=0;i<m;i+=k){
for(int y=i;y<i+k&&y<m;y++){
if(p>v[y].first+d)return 0;
}
p++;
}
return 1;
}
int main () {
cin >> n >> d >> m;
for(int i = 0;i<m;i++) {
int p;
cin >> p;
v[i].first = p;
v[i].second = i;
}
sort(v, v+m);
int l = 1, r = m;
int MIN = 1e9;
while(l <= r) {
int mid = (l+r)/2;
if(f(mid)) {
MIN = min(MIN, mid);
r = mid-1;
}
else {
l = mid + 1;
}
}
cout<<MIN<<endl;
for(int i = 0;i<m;i+=MIN) {
for(int j = i;j<i+MIN and j<m;j++) {
cout<<v[j].second+1<<' ';
}
cout<<0<<"\n";
}
for(int i=m/MIN+min(1,m%MIN);i<n;i++){
cout<<0<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
1760 KB |
Output isn't correct |
2 |
Incorrect |
53 ms |
1840 KB |
Output isn't correct |
3 |
Incorrect |
106 ms |
1784 KB |
Output isn't correct |
4 |
Incorrect |
52 ms |
1824 KB |
Output isn't correct |
5 |
Incorrect |
53 ms |
1820 KB |
Output isn't correct |
6 |
Incorrect |
59 ms |
1744 KB |
Output isn't correct |
7 |
Incorrect |
62 ms |
1764 KB |
Output isn't correct |
8 |
Incorrect |
59 ms |
1768 KB |
Output isn't correct |
9 |
Correct |
229 ms |
2068 KB |
Output is correct |
10 |
Correct |
237 ms |
1948 KB |
Output is correct |
11 |
Correct |
48 ms |
1768 KB |
Output is correct |
12 |
Correct |
205 ms |
3244 KB |
Output is correct |
13 |
Correct |
166 ms |
4712 KB |
Output is correct |
14 |
Correct |
237 ms |
6264 KB |
Output is correct |
15 |
Incorrect |
253 ms |
7676 KB |
Output isn't correct |
16 |
Correct |
338 ms |
9252 KB |
Output is correct |
17 |
Correct |
384 ms |
10704 KB |
Output is correct |
18 |
Correct |
407 ms |
12156 KB |
Output is correct |
19 |
Correct |
607 ms |
13904 KB |
Output is correct |
20 |
Correct |
448 ms |
10744 KB |
Output is correct |