#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ar array
const int INF = 1e15;
const int MOD = 1e9+7;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, d, m; cin>>n>>d>>m;
vector<ar<int,2>> a(m);
for (int i = 0; i < m; i++) {
cin>>a[i][0]; a[i][1] = i+1;
}
sort(a.begin(), a.end());
auto check = [&](int x) {
vector<int> time(x, 0);
for (int i = 0; i < m; i++) {
if (time[i % x] - a[i][0] > d) return false;
time[i % x] = a[i][0] + 1;
}
return true;
};
int lo = 1, hi = m, mid;
while (lo + 1 < hi) {
// cout<<lo<<" "<<hi<<endl;
mid = (lo + hi)>>1;
if (check(mid)) hi = mid;
else lo = mid;
}
cout<<hi<<"\n";
for (int i = 0; i < m; i++) {
cout<<a[i][1]<<" ";
if ((i+1) % hi == 0) cout<<"0\n";
}
if (m % hi != 0) cout<<"0\n";
for (int i = (m+hi-1)/hi; i < n; i++) {
cout<<"0\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
3044 KB |
Output isn't correct |
2 |
Incorrect |
38 ms |
3044 KB |
Output isn't correct |
3 |
Incorrect |
38 ms |
3044 KB |
Output isn't correct |
4 |
Incorrect |
38 ms |
3044 KB |
Output isn't correct |
5 |
Incorrect |
39 ms |
3044 KB |
Output isn't correct |
6 |
Incorrect |
38 ms |
3044 KB |
Output isn't correct |
7 |
Incorrect |
38 ms |
3044 KB |
Output isn't correct |
8 |
Incorrect |
41 ms |
3044 KB |
Output isn't correct |
9 |
Incorrect |
47 ms |
3172 KB |
Output isn't correct |
10 |
Incorrect |
47 ms |
3192 KB |
Output isn't correct |
11 |
Incorrect |
50 ms |
3172 KB |
Output isn't correct |
12 |
Incorrect |
94 ms |
6232 KB |
Output isn't correct |
13 |
Incorrect |
145 ms |
9144 KB |
Output isn't correct |
14 |
Incorrect |
197 ms |
12492 KB |
Output isn't correct |
15 |
Incorrect |
244 ms |
13764 KB |
Output isn't correct |
16 |
Incorrect |
298 ms |
16316 KB |
Output isn't correct |
17 |
Incorrect |
352 ms |
20788 KB |
Output isn't correct |
18 |
Incorrect |
403 ms |
23296 KB |
Output isn't correct |
19 |
Incorrect |
452 ms |
25900 KB |
Output isn't correct |
20 |
Incorrect |
356 ms |
20660 KB |
Output isn't correct |