제출 #1285547

#제출 시각아이디문제언어결과실행 시간메모리
1285547xnoelJob Scheduling (CEOI12_jobs)C++20
60 / 100
315 ms14016 KiB
#include <bits/stdc++.h> using namespace std; int n,delay,m; map<int,int> mp; vector<pair<int,int>> vp; bool alg(int x){ int preday=0,leftover=0; for (auto [day,count]: mp){ leftover = max(leftover + count - (day - preday) * x, 0); if (leftover > x * delay) return false; preday = day; } int remaining_days = max(0, min(n - preday, delay)); leftover = max(leftover - remaining_days * x, 0); return leftover == 0; } int main(){ //freopen("1.in","r",stdin); cin>>n>>delay>>m; for (int i=0;i<m;i++) { int day; cin>>day; mp[day]++; vp.push_back({day,i+1}); } sort(vp.begin(),vp.end()); // for (auto x: mp) cout<<x.first<<" "<<x.second<<"\n"; // cout<<"\n"; int low=1,high=m; while (low<high){ int mid=(low+high)/2; if (alg(mid)) high=mid; else low=mid+1; } cout<<low<<"\n"; for (int i=0;i<n;i++){ for (int j=0;j<low;j++){ int idx=i*low+j; if (idx>=m) { break; } cout<<vp[idx].second<<" "; } cout<<"0\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...