Submission #1285281

#TimeUsernameProblemLanguageResultExecution timeMemory
1285281xnoelJob Scheduling (CEOI12_jobs)C++20
15 / 100
277 ms21036 KiB
#include <bits/stdc++.h> using namespace std; long long n,delay,m; vector<pair<long long,long long>> vp; bool alg(long long x){ long long idx=0; for (long long day=1;day<=n;day++) { idx=day*x-1; if (idx>=m) return true; if (vp[idx].first+delay<day) { //cout<<"debug: "<<idx<<" "<<vp[idx].first<<" "<<day<<"\n"; return false; } } if (idx<m-1) { //cout<<"debug: "<<idx<<" "<<m<<"\n"; return false; } else return true; } int main(){ cin>>n>>delay>>m; for (long long i=0;i<m;i++) { long long day; cin>>day; vp.push_back({day,i+1}); } sort(vp.begin(),vp.end()); // for (auto x: vp) cout<<x.first<<" "<<x.second<<"\n"; // cout<<"\n"; long long low=1,high=m; while (low<high){ long long mid=(low+high)/2; if (alg(mid)) high=mid; else low=mid+1; } cout<<low<<"\n"; for (long long i=0;i<n;i++) { for (long long j=0;j<low;j++) { long long idx=i*low+j; if (idx>=m) { break; } cout<<vp[idx].second<<" "; } cout<<"0\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...