# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
113336 | 2019-05-25T06:11:07 Z | Kastanda | Job Scheduling (CEOI12_jobs) | C++11 | 222 ms | 20380 KB |
#include<bits/stdc++.h> using namespace std; const int N = 100005; int n, d, q; pair < int , int > qu[N * 10]; vector < int > A[N]; inline bool Solve(int md, bool fnl = 0) { if (fnl) printf("%d\n", md); int l = 0, r = 0; for (int i = 1; i <= n; i++) { if (r - l && qu[l].first < i - d) return 0; for (int id : A[i]) qu[r ++] = make_pair(i, id); for (int j = 0; j < md && l < r; j++) { if (fnl) printf("%d ", qu[l].second); l ++; } if (fnl) printf("0\n"); } if (r - l) return 0; return 1; } int main() { scanf("%d%d%d", &n, &d, &q); for (int i = 1, a; i <= q; i++) scanf("%d", &a), A[a].push_back(i); int le = 0, ri = q, md; while (ri - le > 1) { md = (le + ri) >> 1; if (Solve(md)) ri = md; else le = md; } Solve(ri, 1); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 4592 KB | Output is correct |
2 | Correct | 22 ms | 4600 KB | Output is correct |
3 | Correct | 23 ms | 4564 KB | Output is correct |
4 | Correct | 23 ms | 4600 KB | Output is correct |
5 | Correct | 22 ms | 4592 KB | Output is correct |
6 | Correct | 23 ms | 4700 KB | Output is correct |
7 | Correct | 23 ms | 4720 KB | Output is correct |
8 | Correct | 23 ms | 4592 KB | Output is correct |
9 | Correct | 27 ms | 4864 KB | Output is correct |
10 | Correct | 32 ms | 4856 KB | Output is correct |
11 | Correct | 25 ms | 4608 KB | Output is correct |
12 | Correct | 48 ms | 6520 KB | Output is correct |
13 | Correct | 72 ms | 9208 KB | Output is correct |
14 | Correct | 122 ms | 11096 KB | Output is correct |
15 | Correct | 117 ms | 12836 KB | Output is correct |
16 | Correct | 171 ms | 15352 KB | Output is correct |
17 | Correct | 213 ms | 18044 KB | Output is correct |
18 | Correct | 189 ms | 18800 KB | Output is correct |
19 | Correct | 213 ms | 20380 KB | Output is correct |
20 | Correct | 222 ms | 18020 KB | Output is correct |