Submission #504335

#TimeUsernameProblemLanguageResultExecution timeMemory
504335ac2huJob Scheduling (CEOI12_jobs)C++14
40 / 100
237 ms13872 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int M = 1e6 + 10; pair<int,int> a[M]; int n,d,m; bool check(int mid){ int ans = 0; int k = 1; for(int i = 0;i<m;i+=mid){ ans = max(ans,k - a[i].first); k++; } // cout << mid << " " << k << " " << ans << "\n"; if(ans <= d && !(k > n - d)) return true; else return false; } signed main(){ iostream::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> d >> m; for(int i =0;i<m;i++){ cin >> a[i].first; a[i].second = i; } sort(a,a + m); // for(int i = 0;i<m;i++) // cout << a[i].first << " "; // cout << "\n"; int l = 1,r = m; while(l < r){ int mid = (l + r - 1)/2; if(check(mid)) r = mid; else l = mid + 1; } cout << l << "\n"; int idx = -1; for(int i = 0;i<n;i++){ if(idx == m) cout << 0 << "\n"; else{ int j; int temp = idx; for(j = temp + 1;j<min(temp + l + 1, m);j++){ idx = j; cout << a[idx].second + 1 << " "; } cout << 0 << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...