# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260065 | 2020-08-09T07:57:36 Z | MiricaMatei | Job Scheduling (CEOI12_jobs) | C++17 | 355 ms | 17272 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int MAXM = 1000005; pair<int, int> v[MAXM]; bool ok(int n, int d, int m, int k) { int j = 1; for (int i = 1; i <= n; ++i) { int k1 = k; while (j <= m && v[j].first <= i && k1 > 0) { if (i - v[j].first > d) return 0; j++; k1--; } } return 1; } int main() { //freopen("date.in", "r", stdin); //freopen("date.out", "w", stdout); int n, d, m; scanf("%d%d%d", &n, &d, &m); for (int i = 1; i <= m; ++i) { scanf("%d", &v[i].first); v[i].second = i; } sort(v + 1, v + m + 1); int ans = 0; for (int i = 19; i >= 0; --i) if (ans + (1 << i) < m && !ok(n, d, m, ans + (1 << i))) ans += (1 << i); printf("%d\n", ans + 1); int k = ans + 1, j = 1; for (int i = 1; i <= n; ++i) { int k1 = k; while (j <= m && v[j].first <= i && k1 > 0) { printf("%d ", v[j].second); if (i - v[j].first > d) return 0; j++; k1--; } printf("0\n"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 2040 KB | Output is correct |
2 | Correct | 27 ms | 2048 KB | Output is correct |
3 | Correct | 27 ms | 2040 KB | Output is correct |
4 | Correct | 28 ms | 2040 KB | Output is correct |
5 | Correct | 27 ms | 2048 KB | Output is correct |
6 | Correct | 27 ms | 2048 KB | Output is correct |
7 | Correct | 27 ms | 2048 KB | Output is correct |
8 | Correct | 31 ms | 2040 KB | Output is correct |
9 | Correct | 39 ms | 2168 KB | Output is correct |
10 | Correct | 43 ms | 2168 KB | Output is correct |
11 | Correct | 36 ms | 2044 KB | Output is correct |
12 | Correct | 76 ms | 3968 KB | Output is correct |
13 | Correct | 113 ms | 5756 KB | Output is correct |
14 | Correct | 160 ms | 8180 KB | Output is correct |
15 | Correct | 195 ms | 9720 KB | Output is correct |
16 | Correct | 259 ms | 12160 KB | Output is correct |
17 | Correct | 283 ms | 13992 KB | Output is correct |
18 | Correct | 312 ms | 15224 KB | Output is correct |
19 | Correct | 355 ms | 17272 KB | Output is correct |
20 | Correct | 280 ms | 13944 KB | Output is correct |