Submission #1003377

#TimeUsernameProblemLanguageResultExecution timeMemory
1003377AtinaRJob Scheduling (CEOI12_jobs)C++14
95 / 100
284 ms34684 KiB
#include <bits/stdc++.h> using namespace std; const int MAX=1e6+10; const int N=1e5+10; pair<long long,long long> niza[MAX]; long long n,d,m; vector<long long> ress[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>d>>m; for(long long i=0; i<m; i++) { cin>>niza[i].first; niza[i].second=i+1; } sort(niza,niza+m); long long b=0,e=m+1,i=0; bool flag=true; long long res=0; while(b<=e) { long long mid=(b+e)/2; if(mid==0) { b=mid+1; continue; } i=0; flag=true; for(int day=1; day<=n; day++) { for(int j=0; j<mid; j++) { if(i>=m)break; if(niza[i].first>day)break; if(niza[i].first+d<day) { flag=false; break; } i++; } if(!flag)break; } if(flag) { res=mid; e=mid-1; } else b=mid+1; } cout<<res<<endl; i=0; for(int day=1; day<=n; day++) { for(int j=0; j<res; j++) { if(i>=m)break; if(niza[i].first>day)break; ress[day].push_back(niza[i].second); i++; } } for(long long i=1; i<=n; i++) { for(auto x:ress[i])cout<<x<<" "; cout<<0<<endl; } return 0; } /* 8 2 12 1 2 4 2 1 3 5 6 2 3 6 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...