# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085586 | 2024-09-08T13:00:56 Z | vjudge1 | Job Scheduling (CEOI12_jobs) | C++17 | 197 ms | 17236 KB |
#include <iostream> #include <algorithm> using namespace std; const int M = 1e6 + 1, N = 100001; int m, n, d; pair <int, int> job[M]; template <bool write> bool simulate(int maxMachines) { int i = 0, j = 0; for (int day = 1; day <= n; day++) { if (write) cout << '\n'; int machinesLeft = maxMachines; while (j < m && job[j].first == day) j++; while (i < j && machinesLeft) { if (job[i].first + d < day) return false; machinesLeft--; if (write) cout << job[i].second << ' '; i++; } if (write) cout << 0; } return true; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> d >> m; for (int i = 0; i < m; i++) { cin >> job[i].first; job[i].second = i + 1; } sort(job, job + m); // for (int i = 0; i < m; i++) cerr << job[i].second << '\n'; int l = 0, r = m, ans; while (l <= r) { int mid = l + r >> 1; if (simulate<false>(mid)) { ans = mid; r = mid - 1; } else l = mid + 1; } cout << ans; simulate<true>(ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 2136 KB | Output is correct |
2 | Correct | 13 ms | 2136 KB | Output is correct |
3 | Correct | 13 ms | 2136 KB | Output is correct |
4 | Correct | 14 ms | 2112 KB | Output is correct |
5 | Correct | 13 ms | 2140 KB | Output is correct |
6 | Correct | 14 ms | 2136 KB | Output is correct |
7 | Correct | 13 ms | 2036 KB | Output is correct |
8 | Correct | 13 ms | 2140 KB | Output is correct |
9 | Correct | 24 ms | 2140 KB | Output is correct |
10 | Correct | 24 ms | 2036 KB | Output is correct |
11 | Correct | 19 ms | 2140 KB | Output is correct |
12 | Correct | 40 ms | 4060 KB | Output is correct |
13 | Correct | 59 ms | 5716 KB | Output is correct |
14 | Correct | 87 ms | 8040 KB | Output is correct |
15 | Correct | 98 ms | 9552 KB | Output is correct |
16 | Correct | 148 ms | 12112 KB | Output is correct |
17 | Correct | 145 ms | 13936 KB | Output is correct |
18 | Correct | 163 ms | 15116 KB | Output is correct |
19 | Correct | 197 ms | 17236 KB | Output is correct |
20 | Correct | 156 ms | 13904 KB | Output is correct |