# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
860679 | 2023-10-13T17:07:11 Z | agawron | Job Scheduling (CEOI12_jobs) | C++14 | 279 ms | 21228 KB |
#include<iostream> #include<cstdio> #include<vector> using namespace std; const int MAX_N = 1e5 + 5; int n, d, m; vector <int> p[MAX_N], ans[MAX_N]; bool check(int x){ for(int i = 1; i <= n; i++) ans[i].clear(); for(int i = 1, idx = 1 ; i <= n; idx = max(idx, ++i)){ for(int id: p[i]){ if(ans[idx].size() == x) idx++; if(idx > i + d) return 0; ans[idx].push_back(id); } } return 1; } int main(){ scanf("%d %d %d", &n, &d, &m); for(int i = 0; i < m; i++){ int x; scanf("%d", &x); p[x].push_back(i + 1); } int lo = 1; int hi = m; int mi; while(lo < hi){ mi = (lo + hi)/2; if(check(mi)) hi = mi; else lo = mi + 1; } check(lo); printf("%d\n", lo); for(int i = 1; i <= n; i++){ for(int id: ans[i]){ printf("%d ", id); } puts("0"); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 7376 KB | Output is correct |
2 | Correct | 28 ms | 6996 KB | Output is correct |
3 | Correct | 27 ms | 6864 KB | Output is correct |
4 | Correct | 28 ms | 6868 KB | Output is correct |
5 | Correct | 31 ms | 6856 KB | Output is correct |
6 | Correct | 28 ms | 6860 KB | Output is correct |
7 | Correct | 29 ms | 6860 KB | Output is correct |
8 | Correct | 30 ms | 6912 KB | Output is correct |
9 | Correct | 39 ms | 7200 KB | Output is correct |
10 | Correct | 31 ms | 7248 KB | Output is correct |
11 | Correct | 29 ms | 7156 KB | Output is correct |
12 | Correct | 62 ms | 8868 KB | Output is correct |
13 | Correct | 93 ms | 12132 KB | Output is correct |
14 | Correct | 127 ms | 13924 KB | Output is correct |
15 | Correct | 158 ms | 15060 KB | Output is correct |
16 | Correct | 193 ms | 17624 KB | Output is correct |
17 | Correct | 236 ms | 21156 KB | Output is correct |
18 | Correct | 244 ms | 20008 KB | Output is correct |
19 | Correct | 279 ms | 21000 KB | Output is correct |
20 | Correct | 227 ms | 21228 KB | Output is correct |