# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
565309 | 2022-05-20T16:22:23 Z | PranjalChandra | Job Scheduling (CEOI12_jobs) | C++14 | 340 ms | 20412 KB |
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit; #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int N = 1e5 + 10; vector<int> p[N], ans[N]; int n, d, m; 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 = 1; i <= m; i++) { int x; scanf("%d", &x); p[x].push_back(i); } int lo = 1, hi = m, idx; while(lo <= hi) { int mid = lo + hi >> 1; if(check(mid)) idx = mid, hi = mid - 1; else lo = mid + 1; } check(idx); printf("%d\n", idx); for(int i = 1; i <= n; i++) { for(int id : ans[i]) printf("%d ", id); puts("0"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 6568 KB | Output is correct |
2 | Correct | 34 ms | 6568 KB | Output is correct |
3 | Correct | 32 ms | 6568 KB | Output is correct |
4 | Correct | 33 ms | 6556 KB | Output is correct |
5 | Correct | 33 ms | 6632 KB | Output is correct |
6 | Correct | 34 ms | 6552 KB | Output is correct |
7 | Correct | 33 ms | 6580 KB | Output is correct |
8 | Correct | 35 ms | 6552 KB | Output is correct |
9 | Correct | 43 ms | 6860 KB | Output is correct |
10 | Correct | 43 ms | 6940 KB | Output is correct |
11 | Correct | 35 ms | 6584 KB | Output is correct |
12 | Correct | 72 ms | 8240 KB | Output is correct |
13 | Correct | 106 ms | 11180 KB | Output is correct |
14 | Correct | 159 ms | 13092 KB | Output is correct |
15 | Correct | 168 ms | 14084 KB | Output is correct |
16 | Correct | 219 ms | 16140 KB | Output is correct |
17 | Correct | 274 ms | 20412 KB | Output is correct |
18 | Correct | 291 ms | 19116 KB | Output is correct |
19 | Correct | 340 ms | 19916 KB | Output is correct |
20 | Correct | 277 ms | 20168 KB | Output is correct |