#include <bits/stdc++.h>
#pragma GCC Optimize("O3")
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
pair<ll, ll> a[1000001];
bool check(ll machines, ll jobs, ll delay) {
FOR(i, 0, jobs) {
if (i / machines + 1 - a[i].first > delay) return false;
}
return true;
}
int main() {
iostream::sync_with_stdio(false);
cin.tie(0);
ll n, d, m;
cin >> n >> d >> m;
FOR(i, 0, m) {
cin >> a[i].first;
a[i].second = i + 1;
}
sort(a, a + m);
ll l = 0, r = m;
while (l != r) {
ll 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")
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
2556 KB |
Output isn't correct |
2 |
Incorrect |
40 ms |
2552 KB |
Output isn't correct |
3 |
Incorrect |
42 ms |
2464 KB |
Output isn't correct |
4 |
Incorrect |
42 ms |
2552 KB |
Output isn't correct |
5 |
Incorrect |
42 ms |
2552 KB |
Output isn't correct |
6 |
Incorrect |
42 ms |
2552 KB |
Output isn't correct |
7 |
Incorrect |
41 ms |
2552 KB |
Output isn't correct |
8 |
Incorrect |
43 ms |
2552 KB |
Output isn't correct |
9 |
Correct |
51 ms |
2808 KB |
Output is correct |
10 |
Correct |
51 ms |
2680 KB |
Output is correct |
11 |
Correct |
50 ms |
2424 KB |
Output is correct |
12 |
Correct |
105 ms |
4796 KB |
Output is correct |
13 |
Correct |
153 ms |
7160 KB |
Output is correct |
14 |
Correct |
213 ms |
9336 KB |
Output is correct |
15 |
Incorrect |
257 ms |
11512 KB |
Output isn't correct |
16 |
Correct |
310 ms |
13924 KB |
Output is correct |
17 |
Correct |
379 ms |
16120 KB |
Output is correct |
18 |
Correct |
442 ms |
18424 KB |
Output is correct |
19 |
Correct |
491 ms |
20984 KB |
Output is correct |
20 |
Correct |
378 ms |
16120 KB |
Output is correct |