# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1051876 | 2024-08-10T10:22:03 Z | manhlinh1501 | Job Scheduling (CEOI12_jobs) | C++17 | 83 ms | 38296 KB |
#include <bits/stdc++.h> using namespace std; using i64 = long long; using pii = pair<int, int>; const int MAXN = 1e6 + 5; int N, M, D; int a[MAXN]; vector<int> g[MAXN]; bool check(int K) { int cnt = 0; for(int i = 1; i <= N; i++) { cnt += g[i].size(); if(cnt > K * D) return false; cnt = cnt - min(cnt, K); } return true; } signed main() { #define TASK "code" if (fopen(TASK ".inp", "r")) { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> D >> M; for(int i = 1; i <= M; i++) { cin >> a[i]; } for(int i = 1; i <= M; i++) g[a[i]].emplace_back(i); int low = 1, high = M; int ans = -1; while(low <= high) { int mid = (low + high) / 2; if(check(mid)) { ans = mid; high = mid - 1; } else low = mid + 1; } cout << ans << "\n"; queue<int> Q; for(int i = 1; i <= N; i++) { for(int p : g[i]) Q.emplace(p); int cnt = 0; while(!Q.empty() and cnt < ans) { int p = Q.front(); cout << p << " "; Q.pop(); cnt++; } cout << "0\n"; } return (0 ^ 0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 26584 KB | Output isn't correct |
2 | Incorrect | 11 ms | 26588 KB | Output isn't correct |
3 | Incorrect | 11 ms | 26584 KB | Output isn't correct |
4 | Incorrect | 11 ms | 26584 KB | Output isn't correct |
5 | Incorrect | 12 ms | 26588 KB | Output isn't correct |
6 | Incorrect | 16 ms | 26672 KB | Output isn't correct |
7 | Incorrect | 11 ms | 26588 KB | Output isn't correct |
8 | Incorrect | 12 ms | 26588 KB | Output isn't correct |
9 | Incorrect | 15 ms | 26488 KB | Output isn't correct |
10 | Incorrect | 15 ms | 26504 KB | Output isn't correct |
11 | Correct | 12 ms | 26204 KB | Output is correct |
12 | Incorrect | 19 ms | 27484 KB | Output isn't correct |
13 | Correct | 32 ms | 29272 KB | Output is correct |
14 | Incorrect | 40 ms | 32592 KB | Output isn't correct |
15 | Runtime error | 42 ms | 33620 KB | Memory limit exceeded |
16 | Runtime error | 57 ms | 35152 KB | Memory limit exceeded |
17 | Runtime error | 65 ms | 37204 KB | Memory limit exceeded |
18 | Runtime error | 66 ms | 37204 KB | Memory limit exceeded |
19 | Runtime error | 83 ms | 38296 KB | Memory limit exceeded |
20 | Runtime error | 66 ms | 37204 KB | Memory limit exceeded |