제출 #1199488

#제출 시각아이디문제언어결과실행 시간메모리
1199488WarinchaiJob Scheduling (CEOI12_jobs)C++20
0 / 100
234 ms22372 KiB
#include<bits/stdc++.h> using namespace std; int ar[100005]; vector<int>v[100005]; int n,d,m; vector<vector<int>>ans; bool check(int md){ deque<pair<int,int>>dq; ans.clear(); for(int i=1;i<=n;i++){ for(int j=0;j<ar[i];j++)dq.push_back({i,v[i][j]}); vector<int>temp; for(int j=0;j<md;j++){ if(dq.empty())break; int x=i-dq.front().first; if(x>d)return false; temp.push_back(dq.front().second); dq.pop_front(); } temp.push_back(0); ans.push_back(temp); } if(!dq.empty())return false; return true; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>d>>m; for(int i=1;i<=m;i++){ int x;cin>>x; ar[x]++; v[x].push_back(i); } int st=1,en=m,tans=m; while(st<=en){ int md=(st+en)/2; if(check(md)){ en=md-1; tans=md; }else{ st=md+1; } } check(tans); cout<<tans<<"\n"; int cnt=0; for(auto x:ans){ for(auto y:x)cout<<y<<" "; cout<<"\n"; cnt++; if(cnt==n)return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...