# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
160628 | 2019-10-29T01:28:51 Z | luciocf | Job Scheduling (CEOI12_jobs) | C++14 | 377 ms | 13832 KB |
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; typedef pair<int, int> pii; const int maxn = 1e6+10; int n, d, m; pii a[maxn]; bool ok(int x) { int cur_d = 1; for (int i = 1; i <= m; i++) { int j = i; for (; j <= m && a[j].ff <= cur_d && j-i+1 <= x; j++) if (cur_d > a[j].ff+d) return 0; i = j-1; cur_d++; } return 1; } int busca(void) { int ini = 1, fim = m, ans = m; while (ini <= fim) { int mid = (ini+fim)>>1; if (ok(mid)) ans = mid, fim = mid-1; else ini = mid+1; } return ans; } int main(void) { scanf("%d %d %d", &n, &d, &m); for (int i = 1; i <= m; i++) { scanf("%d", &a[i].ff); a[i].ss = i; } sort(a+1, a+m+1); int ans = busca(); printf("%d\n", ans); int cur_d = 1, ind = 1; for (int i = 1; i <= n; i++) { int ant = ind; for (; ind <= m && a[ind].ff <= cur_d && ind-ant+1 <= ans; ind++) printf("%d ", a[ind].ss); printf("0\n"); cur_d++; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 1784 KB | Output is correct |
2 | Correct | 26 ms | 1784 KB | Output is correct |
3 | Correct | 26 ms | 1756 KB | Output is correct |
4 | Correct | 25 ms | 1756 KB | Output is correct |
5 | Correct | 26 ms | 1760 KB | Output is correct |
6 | Correct | 26 ms | 1784 KB | Output is correct |
7 | Correct | 26 ms | 1656 KB | Output is correct |
8 | Correct | 26 ms | 1756 KB | Output is correct |
9 | Correct | 39 ms | 1956 KB | Output is correct |
10 | Correct | 39 ms | 2168 KB | Output is correct |
11 | Correct | 37 ms | 1656 KB | Output is correct |
12 | Correct | 72 ms | 3212 KB | Output is correct |
13 | Correct | 108 ms | 4616 KB | Output is correct |
14 | Correct | 151 ms | 6188 KB | Output is correct |
15 | Correct | 193 ms | 7676 KB | Output is correct |
16 | Correct | 227 ms | 9208 KB | Output is correct |
17 | Correct | 266 ms | 10688 KB | Output is correct |
18 | Correct | 313 ms | 12124 KB | Output is correct |
19 | Correct | 377 ms | 13832 KB | Output is correct |
20 | Correct | 265 ms | 10664 KB | Output is correct |