Submission #570458

#TimeUsernameProblemLanguageResultExecution timeMemory
570458gcconureJob Scheduling (CEOI12_jobs)C++17
0 / 100
411 ms20868 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll n,d,m; vector<pair<ll,ll>> v; bool ok(ll dd){ ll day = 1; ll w = 0; while(w<m){ if(day>n){ return false; } for(ll i = 0; i < dd; i++){ if(w>m){ break; } if(v[w].first+d<day){ return false; } w++; } day++; } return true; } int main(){ cin >> n >> d >> m; for(ll i = 0; i < m; i++){ ll x; cin >> x; v.push_back({x,i}); } sort(v.begin(), v.end()); ll l = 1,r=m; while(l<r){ ll mid = (l+r)/2; if(ok(mid)){ r=mid; } else{ l=mid+1; } } ll counter = 0; cout << l << "\n"; int cur = 0; while(cur<m){ counter++; for(int i = 0; i < l; i++){ cout << v[cur].second+1 << " "; cur++; } cout << "0\n"; } for(ll i = 0; i < n-counter; i++){ cout << 0 << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...