#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
int T, n, m, d;
vector <pair<int,int>> a;
bool check(int x){
int ind = -1, day = 0;
while(ind < m-1){
day++;
for(int i = ind+1; i <= min(ind+x,m-1); i++){
if(a[i].ff + d < day){
return false;
}
}
ind += x;
}
if(day > n) return false;
return true;
}
int main(){
cin >> n >> d >> m;
a.resize(m);
for(int i = 0; i < m; i++){
cin >> a[i].ff;
a[i].ss = i+1;
}
sort(a.begin(), a.end());
int l = 1, r = m, k = m;
while(l <= r){
int md = (l + r) / 2;
if(check(md)){
r = md-1;
k = md;
}
else {
l = md+1;
}
}
cout << k << '\n';
int ind = -1, cnt = 0;
while(ind < m-1){
cnt++;
for(int i = ind+1; i <= min(ind+k,m-1); i++){
cout << a[i].ss << " ";
}
ind += k;
cout << "0\n";
}
for(int i = cnt+1; i <= n; i++){
cout << "0\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
1616 KB |
Output isn't correct |
2 |
Incorrect |
38 ms |
1636 KB |
Output isn't correct |
3 |
Incorrect |
20 ms |
1708 KB |
Output isn't correct |
4 |
Incorrect |
23 ms |
1728 KB |
Output isn't correct |
5 |
Incorrect |
23 ms |
1616 KB |
Output isn't correct |
6 |
Incorrect |
20 ms |
1672 KB |
Output isn't correct |
7 |
Incorrect |
33 ms |
1612 KB |
Output isn't correct |
8 |
Incorrect |
23 ms |
1616 KB |
Output isn't correct |
9 |
Correct |
27 ms |
1780 KB |
Output is correct |
10 |
Correct |
40 ms |
2004 KB |
Output is correct |
11 |
Correct |
28 ms |
1720 KB |
Output is correct |
12 |
Correct |
54 ms |
3268 KB |
Output is correct |
13 |
Correct |
82 ms |
4572 KB |
Output is correct |
14 |
Correct |
115 ms |
6220 KB |
Output is correct |
15 |
Incorrect |
176 ms |
7496 KB |
Output isn't correct |
16 |
Correct |
189 ms |
9212 KB |
Output is correct |
17 |
Correct |
212 ms |
10516 KB |
Output is correct |
18 |
Correct |
246 ms |
12072 KB |
Output is correct |
19 |
Correct |
258 ms |
13640 KB |
Output is correct |
20 |
Correct |
220 ms |
10568 KB |
Output is correct |