# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
708323 | 2023-03-11T14:58:51 Z | Alihan_8 | Job Scheduling (CEOI12_jobs) | C++17 | 284 ms | 20984 KB |
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, D, m; cin >> n >> D >> m; vector <pair<int,int>> p; for ( int i = 0; i < m; i++ ){ int x; cin >> x; p.pb({x, i}); } sort(all(p)); auto ok = [&](int x){ int i = 0, j = 0; for ( int day = 1; day <= n; day++ ){ int K = x; j = i; while ( K > 0 and j < m and p[j].first <= day ){ if ( p[j].first+D < day ) return false; j++; K--; } i = j; } return i == m; }; int l = 1, r = 1e15; while ( l < r ){ int md = (l+r) >> 1; if ( ok(md) ) r = md; else l = md+1; } cout << l << ln; int i = 0, j = 0; for ( int day = 1; day <= n; day++ ){ int K = l; j = i; while ( j < m and K > 0 and p[j].first <= day ){ cout << p[j].second+1 << ' '; j++; K--; } i = j; cout << "0\n"; } cout << '\n'; } /* 8 2 12 1 2 4 2 1 3 5 6 2 3 6 4 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 2588 KB | Output is correct |
2 | Correct | 21 ms | 2552 KB | Output is correct |
3 | Correct | 20 ms | 2628 KB | Output is correct |
4 | Correct | 20 ms | 2636 KB | Output is correct |
5 | Correct | 21 ms | 2564 KB | Output is correct |
6 | Correct | 22 ms | 2628 KB | Output is correct |
7 | Correct | 22 ms | 2544 KB | Output is correct |
8 | Correct | 21 ms | 2628 KB | Output is correct |
9 | Correct | 31 ms | 2796 KB | Output is correct |
10 | Correct | 33 ms | 2692 KB | Output is correct |
11 | Correct | 29 ms | 2540 KB | Output is correct |
12 | Correct | 60 ms | 4812 KB | Output is correct |
13 | Correct | 89 ms | 8648 KB | Output is correct |
14 | Correct | 122 ms | 9396 KB | Output is correct |
15 | Correct | 145 ms | 11628 KB | Output is correct |
16 | Correct | 201 ms | 16804 KB | Output is correct |
17 | Correct | 262 ms | 16784 KB | Output is correct |
18 | Correct | 260 ms | 18456 KB | Output is correct |
19 | Correct | 284 ms | 20984 KB | Output is correct |
20 | Correct | 225 ms | 16820 KB | Output is correct |