제출 #1029510

#제출 시각아이디문제언어결과실행 시간메모리
1029510ArthuroWichJob Scheduling (CEOI12_jobs)C++17
55 / 100
363 ms21460 KiB
#include <bits/stdc++.h> using namespace std; bool check(vector<int> a, int mi, int n, int d) { int i = 1; while(a.size() && i <= n) { for (int j = 0; j < mi; j++) { if (a.empty()) { break; } if (i > a.back()+d) { return 0; } a.pop_back(); } i++; } return a.size() == 0; } void solve() { int n, d, m; cin >> n >> d >> m; vector<int> a(m); vector<pair<int, int>> ans; for (int i = 0; i < m; i++) { cin >> a[i]; ans.push_back({a[i], i}); } sort(a.rbegin(), a.rend()); sort(ans.begin(), ans.end()); int l = 1, r = n; while(l < r) { int mi = (l+r)/2; if (check(a, mi, n, d)) { r = mi; } else { l = mi+1; } } cout << l << endl; int j = 0; for (int i = 0; i < n; i++) { int c = l; while(j < m && c--) { cout << ans[j].second+1 << " "; j++; } cout << 0 << endl; } } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int t; t = 1; while(t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...