제출 #881266

#제출 시각아이디문제언어결과실행 시간메모리
881266votranngocvyJob Scheduling (CEOI12_jobs)C++14
60 / 100
219 ms23888 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fi first #define se second const int N = 1e5 + 5; const int M = 1e6 + 5; vector<int>vec[N]; pii a[M]; int n,d,m; bool check(int val) { int day = 1,cnt = 0; for (int i = 1; i <= m; i++) { if (cnt == val) day++,cnt = 0; if (day < a[i].fi) day = a[i].fi,cnt = 1; if (day > a[i].fi && day - a[i].fi > d) return false; cnt++; } if (day > n) return false; return true; } int tknp(int l,int r) { int ans = r + 1; while (l <= r) { int mid = (l + r) / 2; if (check(mid)) ans = min(ans,mid),r = mid - 1; else l = mid + 1; } return ans; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> d >> m; for (int i = 1; i <= m; i++) { cin >> a[i].fi; a[i].se = i; } sort(a + 1,a + m + 1); int ans = tknp(1,m); cout << ans << "\n"; int day = 0,cnt = 0; for (int i = 1; i <= m; i++) { if (cnt == ans) day++,cnt = 0; if (day < a[i].fi) day = a[i].fi,cnt = 0; vec[day].push_back(a[i].se); cnt++; } for (int i = 1; i <= n; i++) { for (auto x: vec[i]) cout << x << " "; cout << 0 << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...