# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1012102 | 2024-07-01T16:07:16 Z | ThommyDB | Job Scheduling (CEOI12_jobs) | C++17 | 524 ms | 25172 KB |
#include<bits/stdc++.h> using namespace std; int n, d, m; vector<int> requests; map<int,vector<int>> days; bool possible(int machines){ queue<int> q; for(int i = 0; i < n; i++){ for(int job = 0; job < days[i].size(); job++){ q.push(i); } for(int j = 0; j < machines; j++){ if(q.empty())break; if(i-q.front() > d)return false; q.pop(); } } if(q.empty()){ return true; } return false; } signed main(){ cin >> n >> d >> m; requests.resize(m); for(int i = 0; i < m; i++){ cin >> requests[i]; requests[i]--; days[requests[i]].push_back(i+1); } int machines = 0; int l = 1, r = 1e6; while(l < r){ machines = r-(r-l)/2; //cout << l << "&&" << r << "&&" << machines << "\n"; if(possible(machines)){ r=machines-1; } else{ l=machines; } } l++; cout << l << "\n"; queue<pair<int, int>> q; for(int i = 0; i < n; i++){ for(int job = 0; job < days[i].size(); job++){ q.push({d, days[i][job]}); } for(int j = 0; j < l; j++){ if(q.empty())break; cout << q.front().second << " "; q.pop(); } cout << "0\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 3480 KB | Output is correct |
2 | Correct | 45 ms | 3480 KB | Output is correct |
3 | Correct | 44 ms | 3480 KB | Output is correct |
4 | Correct | 43 ms | 3484 KB | Output is correct |
5 | Correct | 46 ms | 3484 KB | Output is correct |
6 | Correct | 47 ms | 3672 KB | Output is correct |
7 | Correct | 47 ms | 3480 KB | Output is correct |
8 | Correct | 40 ms | 3540 KB | Output is correct |
9 | Correct | 138 ms | 10324 KB | Output is correct |
10 | Correct | 138 ms | 10320 KB | Output is correct |
11 | Correct | 45 ms | 2384 KB | Output is correct |
12 | Correct | 74 ms | 4512 KB | Output is correct |
13 | Correct | 111 ms | 6992 KB | Output is correct |
14 | Correct | 262 ms | 10260 KB | Output is correct |
15 | Correct | 190 ms | 10484 KB | Output is correct |
16 | Correct | 333 ms | 14428 KB | Output is correct |
17 | Correct | 404 ms | 16724 KB | Output is correct |
18 | Correct | 369 ms | 16464 KB | Output is correct |
19 | Correct | 524 ms | 25172 KB | Output is correct |
20 | Correct | 395 ms | 17188 KB | Output is correct |