Submission #1270350

#TimeUsernameProblemLanguageResultExecution timeMemory
1270350victorj0902Job Scheduling (CEOI12_jobs)C++20
55 / 100
219 ms20084 KiB
#include<bits/stdc++.h> using namespace std; struct job{ int time; int idx; bool operator < (const job & other){ return time < other.time; } }; job a[1000010]; int n, m, d; bool check(int k){ int curtime = 1; for(int i = 1; i <= m; i+=k){ if(curtime > n) return false; if(a[i].time < curtime){ return false; } curtime++; } return true; } vector<vector<int>> ans(100010); bool cmp(int a, int b){ return a > b; } int main(){ cin >> n >> d >> m; for(int i = 1; i <= m; i++){ cin >> a[i].time; a[i].time += d; a[i].idx = i; } sort(a+1, a+m+1); int l = 1, r = m; int mid; int num = m; while(l <= r){ mid = (l+r)/2; if(check(mid) == true){ num = mid; r = mid-1; }else{ l = mid+1; } } cout << num << endl; for(int i = 1; i <= m; i++){ ans[((i-1)/num)+1].push_back(a[i].idx); } for(int i = 1; i <= n; i++){ for(auto j : ans[i]){ cout << j << " "; } cout << "0\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...