제출 #1204741

#제출 시각아이디문제언어결과실행 시간메모리
1204741nathlol2Job Scheduling (CEOI12_jobs)C++20
55 / 100
203 ms19308 KiB
#include <bits/stdc++.h> #define f first #define s second using namespace std; const int mxN = 1e6; pair<int, int> a[mxN]; int d, l, n; vector<vector<int>> ans; bool ok(int x){ ans.clear(); ans.resize(d); int nx = x, cur = 1; for(int i = 0;i<n;i++){ if(i == nx){ nx += x; ++cur; } if(a[i].f + l < cur){ return false; } ans[cur - 1].push_back(a[i].s); } return true; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> d >> l >> n; ans.resize(d); for(int i = 0;i<n;i++){ cin >> a[i].f; a[i].s = i + 1; } sort(a, a + n); int l = 1, r = n, x = n; while(l <= r){ int mid = (l + r) / 2; if(ok(mid)){ x = mid; r = mid - 1; }else{ l = mid + 1; } } cout << x << '\n'; for(int i = 0;i<d;i++){ for(auto e : ans[i]){ cout << e << ' '; } cout << "0\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...