#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[1000000];
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 |
21 ms |
2040 KB |
Output isn't correct |
2 |
Incorrect |
21 ms |
2040 KB |
Output isn't correct |
3 |
Incorrect |
22 ms |
2040 KB |
Output isn't correct |
4 |
Incorrect |
21 ms |
2040 KB |
Output isn't correct |
5 |
Incorrect |
22 ms |
2028 KB |
Output isn't correct |
6 |
Incorrect |
21 ms |
2040 KB |
Output isn't correct |
7 |
Incorrect |
21 ms |
2040 KB |
Output isn't correct |
8 |
Incorrect |
21 ms |
2040 KB |
Output isn't correct |
9 |
Correct |
58 ms |
2296 KB |
Output is correct |
10 |
Correct |
33 ms |
2168 KB |
Output is correct |
11 |
Incorrect |
30 ms |
2040 KB |
Output isn't correct |
12 |
Correct |
61 ms |
3960 KB |
Output is correct |
13 |
Incorrect |
93 ms |
5880 KB |
Output isn't correct |
14 |
Correct |
126 ms |
8120 KB |
Output is correct |
15 |
Incorrect |
150 ms |
9592 KB |
Output isn't correct |
16 |
Correct |
189 ms |
12176 KB |
Output is correct |
17 |
Incorrect |
226 ms |
14072 KB |
Output isn't correct |
18 |
Correct |
242 ms |
15096 KB |
Output is correct |
19 |
Correct |
275 ms |
17144 KB |
Output is correct |
20 |
Incorrect |
223 ms |
13912 KB |
Output isn't correct |