# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
54495 | 2018-07-03T17:09:59 Z | Bruteforceman | Job Scheduling (CEOI12_jobs) | C++11 | 428 ms | 24348 KB |
#include <bits/stdc++.h> using namespace std; typedef pair <int, int> pii; vector <int> g[100010]; int n, m, d; int a[1000010]; bool good(int x) { queue <int> Q; for(int i = 1; i <= n; i++) { for(auto j : g[i]) { Q.push(j); } for(int j = 0; j < x && !Q.empty(); j++) { int u = Q.front(); Q.pop(); if(i - a[u] > d) return false; } } return Q.empty(); } void print(int x) { printf("%d\n", x); queue <int> Q; for(int i = 1; i <= n; i++) { for(auto j : g[i]) { Q.push(j); } for(int j = 0; j < x && !Q.empty(); j++) { int u = Q.front(); Q.pop(); printf("%d ", u); } printf("0\n"); } return ; } int search(int b, int e) { if(b == e) { return b; } int m = (b + e) >> 1; if(good(m)) return search(b, m); else return search(m + 1, e); } int main (int argc, char const* argv[]) { scanf("%d %d %d", &n, &d, &m); for(int i = 1; i <= m; i++) { scanf("%d", &a[i]); g[a[i]].push_back(i); } print(search(0, m)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 4716 KB | Output is correct |
2 | Correct | 39 ms | 5140 KB | Output is correct |
3 | Correct | 58 ms | 5444 KB | Output is correct |
4 | Correct | 34 ms | 5444 KB | Output is correct |
5 | Correct | 34 ms | 5444 KB | Output is correct |
6 | Correct | 36 ms | 5516 KB | Output is correct |
7 | Correct | 34 ms | 5516 KB | Output is correct |
8 | Correct | 36 ms | 5516 KB | Output is correct |
9 | Correct | 46 ms | 5660 KB | Output is correct |
10 | Correct | 61 ms | 5660 KB | Output is correct |
11 | Correct | 50 ms | 5660 KB | Output is correct |
12 | Correct | 96 ms | 6880 KB | Output is correct |
13 | Correct | 113 ms | 9016 KB | Output is correct |
14 | Correct | 184 ms | 10812 KB | Output is correct |
15 | Correct | 173 ms | 11960 KB | Output is correct |
16 | Correct | 256 ms | 14124 KB | Output is correct |
17 | Correct | 343 ms | 16452 KB | Output is correct |
18 | Correct | 327 ms | 19720 KB | Output is correct |
19 | Correct | 428 ms | 24348 KB | Output is correct |
20 | Correct | 323 ms | 24348 KB | Output is correct |