Submission #1062290

#TimeUsernameProblemLanguageResultExecution timeMemory
1062290Kiet07Job Scheduling (CEOI12_jobs)C++14
25 / 100
1048 ms65536 KiB
#include<bits/stdc++.h> using namespace std; int n,m,d; bool check(int x,multiset<pair<int,int>>ms) { for(int days=1;days<=n;days++) { for(int i=1;i<=x;i++) { if(days<=ms.begin()->first+d) { ms.erase(ms.begin()); if(ms.empty()) { return true; } } else { return false; } } } if(ms.empty()) { return true; } else { return false; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("TEST.inp","r",stdin); cin>>n>>d>>m; multiset<pair<int,int>>ms; for(int i=1;i<=m;i++) { int x; cin>>x; ms.insert({x,i}); } int l=1,r=1000000,ans=r; while(l<=r) { int mid=(l+r)/2; if(check(mid,ms)) { ans=mid; r=mid-1; } else { l=mid+1; } } cout<<ans<<'\n'; for(int days=1;days<=n;days++) { if(!ms.empty()) { for(int i=1;i<=ans;i++) { if(days<=ms.begin()->first+d) { cout<<ms.begin()->second<<' '; ms.erase(ms.begin()); if(ms.empty()) { break; } } } } cout<<0<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...