제출 #635626

#제출 시각아이디문제언어결과실행 시간메모리
635626nayhzJob Scheduling (CEOI12_jobs)C++17
95 / 100
561 ms38608 KiB
// CEOI 2012 Dau 1 Job Scheduling #include <bits/stdc++.h> #define pii pair<int, int> #define vi vector<int> #define vpii vector<pair<int, int>> #define fi first #define se second #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() using namespace std; /* >>>>>>>>>>>>>>>>>>>>>>>>>>END OF TEMPLATE HEADER<<<<<<<<<<<<<<<<<<<<<<<< */ void solve () { int n, d, m; cin >> n >> d >> m; vpii a(m); for (int i = 0; i < m; i++) {cin >> a[i].fi; a[i].se = i + 1;} sort(all(a)); vector<vi> ans(n), ret(n); int l = 1, r = m, mid, day, i, cnt; function<pair<bool, vector<vi>> ()> check = [&] () { for (int i = 0; i < n; i++) ret[i].clear(); cnt = 0; for (day = 1; day <= n; day++) { for (i = 0; i < mid; i++) { if (a[cnt].fi > day) break; if (a[cnt].fi + d >= day){ ret[day - 1].pb(a[cnt++].se); } else return mp(false, ret); if (cnt == m) { return mp(true, ret); } } } return mp(false, ret); }; pair<bool, vector<vi>> temp; while (l < r) { mid = l + ((r - l) >> 1); temp = check(); if (temp.fi) { r = mid, ans = temp.se; } else l = mid + 1; } cout << l << '\n'; for (i = 0; i < n; i++) { for (int j = 0; j < (int)ans[i].size(); j++) cout << ans[i][j] << ' '; cout << "0\n"; } } signed main () { solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...