# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
102159 | 2019-03-23T02:38:55 Z | thebes | Job Scheduling (CEOI12_jobs) | C++14 | 476 ms | 16760 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 1e5+5; int N, D, M, i, x, lo, hi, src[10*MN]; vector<int> adj[MN]; queue<int> q; bool check(int m){ while(q.size()) q.pop(); for(int i=1;i<=N;i++){ for(auto v : adj[i]) q.push(v); int sz = min((int)q.size(), m); while(sz--){ if(src[q.front()]+D<i) return 0; q.pop(); } } return q.size()==0; } int main(){ for(scanf("%d%d%d",&N,&D,&M),i=1;i<=M;i++) scanf("%d",&x), adj[x].push_back(i), src[i]=x; lo = 1, hi = M; while(lo<hi){ int m = lo+hi>>1; if(check(m)) hi=m; else lo=m+1; } printf("%d\n",lo); while(q.size()) q.pop(); for(i=1;i<=N;i++){ for(auto v: adj[i]) q.push(v); int sz = min((int)q.size(), lo); while(sz--){ printf("%d ",q.front()); q.pop(); } printf("0\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 4464 KB | Output is correct |
2 | Correct | 28 ms | 4472 KB | Output is correct |
3 | Correct | 53 ms | 4464 KB | Output is correct |
4 | Correct | 30 ms | 4460 KB | Output is correct |
5 | Correct | 33 ms | 4464 KB | Output is correct |
6 | Correct | 30 ms | 4596 KB | Output is correct |
7 | Correct | 35 ms | 4460 KB | Output is correct |
8 | Correct | 30 ms | 4464 KB | Output is correct |
9 | Correct | 36 ms | 4344 KB | Output is correct |
10 | Correct | 40 ms | 4472 KB | Output is correct |
11 | Correct | 37 ms | 4216 KB | Output is correct |
12 | Correct | 85 ms | 5752 KB | Output is correct |
13 | Correct | 167 ms | 7928 KB | Output is correct |
14 | Correct | 250 ms | 9848 KB | Output is correct |
15 | Correct | 159 ms | 10872 KB | Output is correct |
16 | Correct | 456 ms | 13000 KB | Output is correct |
17 | Correct | 476 ms | 15480 KB | Output is correct |
18 | Correct | 398 ms | 15608 KB | Output is correct |
19 | Correct | 411 ms | 16760 KB | Output is correct |
20 | Correct | 340 ms | 15352 KB | Output is correct |