제출 #1162296

#제출 시각아이디문제언어결과실행 시간메모리
1162296PikachudoraEHEJob Scheduling (CEOI12_jobs)C++20
40 / 100
1094 ms23484 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e6+5; int mem[N];vector<int>a;int n,d,m,ma2=0; bool chk(int vv){ priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q; for(int i=1;i<=m;i++){ q.push({a[i-1],i}); } for(int i=1;i<=n;i++){ int dd=0; if(q.top().first<i-d)return false; while(!q.empty() && q.top().first<=i && dd<vv){ q.pop(); dd++; } } if(!q.empty())return false; return true; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>d>>m;int ma = 0; a.resize(m); for(int i=0;i<m;i++){ cin>>a[i]; mem[a[i]]++; ma=max(ma,mem[a[i]]); ma2=max(ma2,a[i]); } int l=1,r=ma; while(l<r){ int mid = (l+r)/2; if(chk(mid)){ r=mid; } else l = mid+1; } cout<<l<<"\n"; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q; for(int i=1;i<=m;i++){ q.push({a[i-1],i}); } for(int i=1;i<=n;i++){ int dd=0; while(!q.empty() && q.top().first<=i && dd<l){ cout << q.top().second << " "; q.pop(); dd++; } cout << "0\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...