Submission #568662

#TimeUsernameProblemLanguageResultExecution timeMemory
568662gcconureJob Scheduling (CEOI12_jobs)C++17
5 / 100
390 ms65536 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll n,d,m; vector<pair<ll,ll>> v; vector<vector<ll>> arr; bool ok(ll dd){ auto copy=v; arr.clear(); for(ll i = 0; i < n; i++){ arr.push_back({}); } ll day = 0; ll done=0; bool works=true; while(done<m){ if(day==n){ works=false; break; } for(ll i = 0; i < min(ll(v.size()+1),ll(dd)); i++){ arr[day].push_back(v.back().second); v.pop_back(); } day++; done+=dd; } v=copy; return works; } int main(){ cin >> n >> d >> m; for(ll i = 0; i < m; i++){ ll x; cin >> x; v.push_back({x,i}); } sort(v.rbegin(), v.rend()); ll l = 1,r=m; vector<vector<ll>> cur; while(l<r){ ll mid = (l+r)/2; if(ok(mid)){ cur=arr; r=mid; } else{ l=mid+1; } } cout << l << "\n"; for(vector<ll> vv:cur){ for(ll i:vv){ cout << i+1 << " "; } cout << 0 << "\n"; } for(ll i = 0; i < ll(n-cur.size()); i++){ cout << 0 << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...