# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
558163 | 2022-05-07T02:06:02 Z | hibiki | Job Scheduling (CEOI12_jobs) | C++11 | 195 ms | 20484 KB |
#include<bits/stdc++.h> using namespace std; #define pb push_back int n,d,m; int work[1000005]; vector<int> day[100005]; int main() { scanf("%d %d %d",&n,&d,&m); for(int i = 1; i <= m; i++) { scanf("%d",&work[i]); day[work[i]].pb(i); } int l = 1, r = m; while(l <= r) { int mid = (l + r) / 2; bool ok = true, ans = false; queue<int> unfin; if(l==r) { ans = true; printf("%d\n",mid); } for(int i = 1; i <= n; i++) { // printf("day %d: ",i); if(!unfin.empty() && work[unfin.front()] + d < i) { ok = false; break; } int done = 0; while(done < mid && !unfin.empty()) { if(ans) printf("%d ",unfin.front()); done++; unfin.pop(); } for(int j: day[i]) { if(done < mid) { if(ans) printf("%d ",j); done++; } else unfin.push(j); } if(ans) printf("0\n"); } if(l==r) break; if(!unfin.empty()) ok = false; if(ok) r = mid; else l = mid + 1; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 4612 KB | Output is correct |
2 | Correct | 31 ms | 4560 KB | Output is correct |
3 | Correct | 23 ms | 4604 KB | Output is correct |
4 | Correct | 25 ms | 4648 KB | Output is correct |
5 | Correct | 22 ms | 4584 KB | Output is correct |
6 | Correct | 24 ms | 4652 KB | Output is correct |
7 | Correct | 26 ms | 4580 KB | Output is correct |
8 | Correct | 25 ms | 4548 KB | Output is correct |
9 | Correct | 26 ms | 4684 KB | Output is correct |
10 | Correct | 33 ms | 4940 KB | Output is correct |
11 | Correct | 22 ms | 4540 KB | Output is correct |
12 | Correct | 45 ms | 6552 KB | Output is correct |
13 | Correct | 87 ms | 9112 KB | Output is correct |
14 | Correct | 98 ms | 11668 KB | Output is correct |
15 | Correct | 93 ms | 12920 KB | Output is correct |
16 | Correct | 131 ms | 15916 KB | Output is correct |
17 | Correct | 177 ms | 18752 KB | Output is correct |
18 | Correct | 167 ms | 18764 KB | Output is correct |
19 | Correct | 195 ms | 20484 KB | Output is correct |
20 | Correct | 171 ms | 18652 KB | Output is correct |