# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
675770 | 2022-12-27T20:15:48 Z | aaggupta07 | Job Scheduling (CEOI12_jobs) | C++17 | 296 ms | 21228 KB |
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; #define MAX_C 1'000'500 #define pb push_back #define pi pair<int, int> #define f first #define s second int n, d, m; vector<pi> requests; bool check(int r) { int days = 0, jobsDone = 0; for(int i = 0; i < m; ++i) { // process r requests per day if(requests[i].f > days) { days = requests[i].f; jobsDone = 1; continue; } if(jobsDone % r == 0 && jobsDone != 0) days += 1; if(days - requests[i].f > d) return false; ++jobsDone; } return true; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> d >> m; requests.resize(m); for(int i = 0; i < m; ++i) { cin >> requests[i].f; requests[i].s = i + 1; } sort(requests.begin(), requests.end()); int ans = MAX_C; for(int b = MAX_C/2; b >= 1; b/=2) { while(ans - b >= 1 && check(ans - b)) ans -= b; } cout << ans << '\n'; int days = 0, jobsDone = 0; vector<vector<int>> schedule(n); for(int i = 0; i < m; ++i) { // process r requests per day if(requests[i].f > days) { days = requests[i].f; jobsDone = 0; } else if(jobsDone % ans == 0 && jobsDone != 0) days += 1; ++jobsDone; schedule[days-1].pb(requests[i].s); } for(auto& i: schedule) { for(int j: i) cout << j << ' '; cout << 0 << '\n'; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 2764 KB | Output is correct |
2 | Correct | 34 ms | 2688 KB | Output is correct |
3 | Correct | 31 ms | 2668 KB | Output is correct |
4 | Correct | 31 ms | 2716 KB | Output is correct |
5 | Correct | 29 ms | 2684 KB | Output is correct |
6 | Correct | 27 ms | 2748 KB | Output is correct |
7 | Correct | 29 ms | 2764 KB | Output is correct |
8 | Correct | 36 ms | 2756 KB | Output is correct |
9 | Correct | 39 ms | 4936 KB | Output is correct |
10 | Correct | 40 ms | 4928 KB | Output is correct |
11 | Correct | 33 ms | 2528 KB | Output is correct |
12 | Correct | 66 ms | 4908 KB | Output is correct |
13 | Correct | 101 ms | 7520 KB | Output is correct |
14 | Correct | 145 ms | 9848 KB | Output is correct |
15 | Correct | 169 ms | 10540 KB | Output is correct |
16 | Correct | 195 ms | 12820 KB | Output is correct |
17 | Correct | 242 ms | 16700 KB | Output is correct |
18 | Correct | 273 ms | 17376 KB | Output is correct |
19 | Correct | 296 ms | 21228 KB | Output is correct |
20 | Correct | 260 ms | 16808 KB | Output is correct |