제출 #94933

#제출 시각아이디문제언어결과실행 시간메모리
94933popovicirobertJob Scheduling (CEOI12_jobs)C++14
100 / 100
231 ms14004 KiB
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long #define ld long double // 217 // 44 using namespace std; const int MAXM = (int) 1e6; pair <int, int> arr[MAXM + 1]; inline bool check(int m, int d, int len) { int pos = 1; int cnt = 0; while(pos <= m) { cnt++; int i; for(i = pos; i < min(m + 1, pos + len) && cnt >= arr[i].first; i++) { if(cnt - arr[i].first > d) { return 0; } } pos = i; } return 1; } int main() { //ifstream cin("A.in"); //ofstream cout("A.out"); int i, n, m, d; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> d >> m; for(i = 1; i <= m; i++) { cin >> arr[i].first; arr[i].second = i; } sort(arr + 1, arr + m + 1); int res = 0; for(int step = 1 << 20; step; step >>= 1) { if(check(m, d, res + step) == 0) { res += step; } } res++; cout << res << "\n"; int pos = 1; int cnt = 0; for(i = 1; i <= n; i++) { int j; cnt++; for(j = pos; j < min(m + 1, pos + res) && cnt >= arr[j].first; j++) { cout << arr[j].second << " "; } cout << "0\n"; pos = j; } //cin.close(); //cout.close(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...