# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
361280 | 2021-01-29T07:08:09 Z | parsabahrami | Job Scheduling (CEOI12_jobs) | C++17 | 337 ms | 20204 KB |
// Call my Name and Save me from The Dark #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; #define SZ(x) (int) x.size() #define F first #define S second const int N = 1e6 + 10; int n, D, m; pii A[N]; vector<int> vec[N / 10]; int check(int x) { for (int i = 1, ptr = 0, cnt = 0; i <= n && ptr < m; i++) { if (i - A[ptr + 1].F > D) return 0; cnt = 0; while (ptr < m && A[ptr + 1].F <= i && cnt < x) ptr++, cnt++; } return 1; } void make(int x) { for (int i = 1, ptr = 0, cnt = 0; i <= n && ptr < m; i++) { assert(i - A[ptr + 1].F <= D); cnt = 0; while (ptr < m && A[ptr + 1].F <= i && cnt < x) { vec[i].push_back(A[ptr + 1].S); ptr++, cnt++; } } } int main() { scanf("%d%d%d", &n, &D, &m); for (int i = 1; i <= m; i++) scanf("%d", &A[i].F), A[i].S = i; sort(A + 1, A + m + 1); int l = 0, r = m + 1; while (r - l > 1) { int mid = (l + r) >> 1; if (check(mid)) r = mid; else l = mid; } printf("%d\n", r); make(r); for (int i = 1; i <= n; i++) { for (int j : vec[i]) { printf("%d ", j); } printf("0\n"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 4716 KB | Output is correct |
2 | Correct | 28 ms | 4588 KB | Output is correct |
3 | Correct | 29 ms | 4588 KB | Output is correct |
4 | Correct | 28 ms | 4588 KB | Output is correct |
5 | Correct | 28 ms | 4716 KB | Output is correct |
6 | Correct | 29 ms | 4588 KB | Output is correct |
7 | Correct | 28 ms | 4588 KB | Output is correct |
8 | Correct | 28 ms | 4588 KB | Output is correct |
9 | Correct | 40 ms | 4844 KB | Output is correct |
10 | Correct | 42 ms | 4844 KB | Output is correct |
11 | Correct | 37 ms | 4588 KB | Output is correct |
12 | Correct | 73 ms | 6508 KB | Output is correct |
13 | Correct | 109 ms | 9068 KB | Output is correct |
14 | Correct | 161 ms | 11244 KB | Output is correct |
15 | Correct | 182 ms | 12140 KB | Output is correct |
16 | Correct | 239 ms | 14316 KB | Output is correct |
17 | Correct | 266 ms | 18172 KB | Output is correct |
18 | Correct | 295 ms | 18668 KB | Output is correct |
19 | Correct | 337 ms | 20204 KB | Output is correct |
20 | Correct | 265 ms | 18156 KB | Output is correct |