# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
230104 | 2020-05-08T09:45:59 Z | PeppaPig | Job Scheduling (CEOI12_jobs) | C++14 | 353 ms | 23928 KB |
#include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second using namespace std; const int N = 1e5+5; int n, m, d; vector<int> job[N], ans[N]; bool solve(int mid) { queue<pii> Q; for(int i = 1; i <= n; i++) ans[i].clear(); for(int i = 1; i <= n; i++) { for(int x : job[i]) Q.emplace(x, i); while(!Q.empty() && ans[i].size() < mid) { pii now = Q.front(); Q.pop(); if(now.y + d < i) return false; ans[i].emplace_back(now.x); } } return Q.empty(); } int main() { scanf("%d %d %d", &n, &d, &m); for(int i = 1, a; i <= m; i++) { scanf("%d", &a); job[a].emplace_back(i); } int l = 0, r = (int)1e6; while(l < r) { int mid = (l + r) >> 1; if(solve(mid)) r = mid; else l = mid + 1; } solve(r); printf("%d\n", r); for(int i = 1; i <= n; i++) { for(int x : ans[i]) printf("%d ", x); printf("0\n"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 7328 KB | Output is correct |
2 | Correct | 48 ms | 7288 KB | Output is correct |
3 | Correct | 50 ms | 7288 KB | Output is correct |
4 | Correct | 48 ms | 7288 KB | Output is correct |
5 | Correct | 57 ms | 7288 KB | Output is correct |
6 | Correct | 49 ms | 7288 KB | Output is correct |
7 | Correct | 49 ms | 7288 KB | Output is correct |
8 | Correct | 49 ms | 7328 KB | Output is correct |
9 | Correct | 55 ms | 7160 KB | Output is correct |
10 | Correct | 56 ms | 7288 KB | Output is correct |
11 | Correct | 48 ms | 7160 KB | Output is correct |
12 | Correct | 84 ms | 9208 KB | Output is correct |
13 | Correct | 128 ms | 12408 KB | Output is correct |
14 | Correct | 196 ms | 15644 KB | Output is correct |
15 | Correct | 198 ms | 16120 KB | Output is correct |
16 | Correct | 265 ms | 19448 KB | Output is correct |
17 | Correct | 344 ms | 23676 KB | Output is correct |
18 | Correct | 321 ms | 22056 KB | Output is correct |
19 | Correct | 353 ms | 23284 KB | Output is correct |
20 | Correct | 331 ms | 23928 KB | Output is correct |