제출 #1199485

#제출 시각아이디문제언어결과실행 시간메모리
1199485WarinchaiJob Scheduling (CEOI12_jobs)C++20
0 / 100
209 ms22244 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); } 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=n,tans=n; while(st<=en){ int m=(st+en)/2; if(check(m)){ en=m-1; tans=m; }else{ st=m+1; } } check(tans); cout<<tans<<"\n"; for(auto x:ans){ for(auto y:x)cout<<y<<" "; cout<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...