Submission #94932

#TimeUsernameProblemLanguageResultExecution timeMemory
94932popovicirobertJob Scheduling (CEOI12_jobs)C++14
55 / 100
239 ms16988 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++; for(int i = pos; i < min(m + 1, pos + len); i++) { if(cnt - arr[i].first > d) { return 0; } } pos += len; } 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; for(i = 1; i <= n; i++) { for(int j = pos; j < min(m + 1, pos + res); j++) { cout << arr[j].second << " "; } cout << "0\n"; pos += res; } //cin.close(); //cout.close(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...