Submission #1104700

#TimeUsernameProblemLanguageResultExecution timeMemory
1104700MuhammetJob Scheduling (CEOI12_jobs)C++17
0 / 100
271 ms16548 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second int T, n, m, d; vector <pair<int,int>> a; bool check(int x){ int ind = -1, day = 0; while(ind < m-1){ day++; for(int i = ind+1; i <= min(ind+x,m-1); i++){ if(a[i].ss + d < day){ return false; } } ind += x; } if(day > n) return false; return true; } int main(){ cin >> n >> d >> m; a.resize(m); for(int i = 0; i < m; i++){ cin >> a[i].ff; a[i].ss = i+1; } sort(a.begin(), a.end()); int l = 1, r = m, k = m; while(l <= r){ int md = (l + r) / 2; if(check(md)){ r = md-1; k = md; } else { l = md+1; } } cout << k << '\n'; int ind = -1, cnt = 0; while(ind < m-1){ cnt++; for(int i = ind+1; i <= min(ind+k,m-1); i++){ cout << a[i].ss << " "; } ind += k; cout << "0\n"; } for(int i = cnt+1; i <= n; i++){ cout << "0\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...