# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
979029 | 2024-05-10T06:35:34 Z | Amaarsaa | Job Scheduling (CEOI12_jobs) | C++14 | 308 ms | 14064 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long ; int n, d; vector < pair < int, int > >v; bool can(int mid) { int i, s, cnt = 0, l, r; l = 0; for (i = 1; i <= n; i ++) { if ( l >= v.size()) return 1; if ( v[l].first < i) return 0; i = max(i, v[l].first - d); r = min(int(v.size() - 1), l + mid - 1); if ( l > r) return 0; l = r + 1; } if ( l >= v.size()) return 1; return 0; } void Ans(int mid) { int i, s, cnt = 0, l, r; l = 0; for (i = 1; i <= n; i ++) { cnt ++; i = max(i, v[l].first - d); r = min(int(v.size() - 1), l + mid - 1); for (int j = l; j <= r; j ++) cout << v[j].second << " "; cout << 0 << endl; l = r + 1; } while ( cnt < n) { cout << 0 << endl; cnt ++; } return ; } int main() { // freopen("moocast.in", "r", stdin); // freopen("moocast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); int m, i,x, lo, hi, mid; cin >> n >> d >> m; for (i = 1; i <= m; i ++) { cin >> x; v.push_back({x + d, i}); } sort(v.begin(), v.end()); lo = 0; hi = m; while (lo < hi) { mid = (lo + hi)/2; if (!can(mid)) lo = mid + 1; else hi = mid; } cout << lo << endl; Ans(lo ); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 1752 KB | Output is correct |
2 | Correct | 23 ms | 1748 KB | Output is correct |
3 | Correct | 24 ms | 1752 KB | Output is correct |
4 | Correct | 25 ms | 1752 KB | Output is correct |
5 | Correct | 28 ms | 1748 KB | Output is correct |
6 | Correct | 24 ms | 2004 KB | Output is correct |
7 | Correct | 24 ms | 1748 KB | Output is correct |
8 | Correct | 32 ms | 2264 KB | Output is correct |
9 | Correct | 137 ms | 2000 KB | Output is correct |
10 | Correct | 127 ms | 2004 KB | Output is correct |
11 | Correct | 20 ms | 1752 KB | Output is correct |
12 | Correct | 43 ms | 3528 KB | Output is correct |
13 | Correct | 61 ms | 5664 KB | Output is correct |
14 | Correct | 93 ms | 6288 KB | Output is correct |
15 | Correct | 97 ms | 7872 KB | Output is correct |
16 | Correct | 132 ms | 11332 KB | Output is correct |
17 | Correct | 152 ms | 11204 KB | Output is correct |
18 | Correct | 175 ms | 14064 KB | Output is correct |
19 | Correct | 308 ms | 14008 KB | Output is correct |
20 | Correct | 160 ms | 12028 KB | Output is correct |