제출 #858457

#제출 시각아이디문제언어결과실행 시간메모리
858457ilefJob Scheduling (CEOI12_jobs)C++14
5 / 100
139 ms2128 KiB
#include <bits/stdc++.h> using namespace std; const int M=1e5+12; int n,d,m; pair<int,int>a[M]; bool good(int num) { int i=0; int day=1; int cnt=0; while(i<m){ if(cnt==num){ cnt=0; day++; } if(a[i].first>day){ day=a[i].first; } if(a[i].first+d<day){ return false; } i++; cnt++; } return day<=n; } int main() { cin>>n>>d>>m; for(int i=0;i<m;i++){ cin>>a[i].first; a[i].second=i; } sort(a,a+m); int l=0; int r=m; int mid=(l+r)/2; while(l+1<r){ mid=(l+r)/2; if(good(mid)){ r=mid; } else{ l=mid; } } int cnt=0; cout<<mid<<endl; int days=1; for(int i=0;i<m;i++){ if(a[i].first<=days){ cout<<a[i].second+1<<" "; cnt++; if(cnt==mid){ cout<<0<<endl; cnt=0; days++;}} else{ cout<<0<<endl; days++; cnt=0; } } for(int i=days;i<=n;i++){ cout<<0<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...