#include <bits/stdc++.h>
#pragma GCC Optimize("O3")
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
pair<int, int> a[1000001];
bool check(int machines, int jobs, int delay) {
for (int i = 0, days = 1; i < jobs; i += machines, days++) {
if (days - a[min(i + machines, jobs) - 1].first >= delay) return false;
}
return true;
}
int main() {
iostream::sync_with_stdio(false);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
FOR(i, 0, m) {
cin >> a[i].first;
a[i].second = i + 1;
}
sort(a, a + m);
int l = 1, r = m;
while (l != r) {
int mid = (l + r) / 2;
if (check(mid, m, d)) r = mid;
else l = mid + 1;
}
cout << l << '\n';
FOR(i, 0, n) {
FOR(j, i * l, min(i * l + l, m)) cout << a[j].second << ' ';
cout << "0\n";
}
return 0;
}
Compilation message
jobs.cpp:2:0: warning: ignoring #pragma GCC Optimize [-Wunknown-pragmas]
#pragma GCC Optimize("O3")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
1784 KB |
Output isn't correct |
2 |
Incorrect |
21 ms |
1784 KB |
Output isn't correct |
3 |
Incorrect |
22 ms |
1784 KB |
Output isn't correct |
4 |
Incorrect |
21 ms |
1784 KB |
Output isn't correct |
5 |
Incorrect |
21 ms |
1788 KB |
Output isn't correct |
6 |
Incorrect |
21 ms |
1784 KB |
Output isn't correct |
7 |
Incorrect |
21 ms |
1812 KB |
Output isn't correct |
8 |
Incorrect |
22 ms |
1784 KB |
Output isn't correct |
9 |
Incorrect |
32 ms |
1944 KB |
Output isn't correct |
10 |
Incorrect |
32 ms |
1912 KB |
Output isn't correct |
11 |
Correct |
31 ms |
1656 KB |
Output is correct |
12 |
Incorrect |
60 ms |
3192 KB |
Output isn't correct |
13 |
Correct |
92 ms |
4660 KB |
Output is correct |
14 |
Incorrect |
132 ms |
6264 KB |
Output isn't correct |
15 |
Incorrect |
150 ms |
7672 KB |
Output isn't correct |
16 |
Correct |
187 ms |
9180 KB |
Output is correct |
17 |
Correct |
221 ms |
10616 KB |
Output is correct |
18 |
Correct |
242 ms |
12224 KB |
Output is correct |
19 |
Incorrect |
274 ms |
13880 KB |
Output isn't correct |
20 |
Correct |
218 ms |
10812 KB |
Output is correct |