# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
711370 | 2023-03-16T18:09:05 Z | damamila | Job Scheduling (CEOI12_jobs) | C++14 | 268 ms | 13876 KB |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, d, m; cin >> n >> d >> m; vector<int> requests(n); vector<vector<int>> auftrage(n); int upper = 0, lower = 1; for (int i = 1; i <= m; i++) { int a; cin >> a; a--; requests[a]++; auftrage[a].push_back(i); upper = max(upper, requests[a]); } //cout << d << endl; while(upper-lower>0){ int maschinen = (lower+upper)/2; //cout << maschinen << endl; int last = 0, rest = requests[0]; bool pos = true; for(int i=0; i<n && pos; i++){ if (i - last > d) { //cout << i << "-" << last << ">" << d << "false" << endl; pos = false; } int tmp = maschinen; while(tmp>0 && last<=i){ int tmp2 = min(rest, tmp); tmp -= tmp2; rest -= tmp2; if(rest == 0 && last<=i){ last++; rest = requests[last]; } } } if(pos){ //cout << maschinen << endl; upper = maschinen; } else lower = maschinen+1; } cout << lower << endl; int curr = 0; int j = auftrage[curr].size()-1; for (int b = 0; b < n; b++) { for (int i = 0; i < lower && b >= curr && curr < auftrage.size() && j >= 0; i++) { cout << auftrage[curr][j] << " "; j--; if (j < 0) { curr++; if(curr < auftrage.size()) j = auftrage[curr].size()-1; } } cout << 0 << endl; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 1232 KB | Output is correct |
2 | Correct | 18 ms | 1148 KB | Output is correct |
3 | Correct | 21 ms | 1232 KB | Output is correct |
4 | Correct | 21 ms | 1232 KB | Output is correct |
5 | Correct | 18 ms | 1232 KB | Output is correct |
6 | Correct | 18 ms | 1248 KB | Output is correct |
7 | Correct | 24 ms | 1232 KB | Output is correct |
8 | Correct | 20 ms | 1232 KB | Output is correct |
9 | Correct | 140 ms | 4544 KB | Output is correct |
10 | Correct | 148 ms | 4496 KB | Output is correct |
11 | Correct | 18 ms | 1496 KB | Output is correct |
12 | Correct | 35 ms | 2592 KB | Output is correct |
13 | Correct | 62 ms | 4472 KB | Output is correct |
14 | Correct | 85 ms | 5952 KB | Output is correct |
15 | Correct | 83 ms | 6824 KB | Output is correct |
16 | Correct | 117 ms | 8588 KB | Output is correct |
17 | Correct | 168 ms | 10540 KB | Output is correct |
18 | Correct | 130 ms | 10584 KB | Output is correct |
19 | Correct | 268 ms | 13876 KB | Output is correct |
20 | Correct | 135 ms | 10592 KB | Output is correct |