제출 #674273

#제출 시각아이디문제언어결과실행 시간메모리
674273thienbao1602Job Scheduling (CEOI12_jobs)C++17
0 / 100
329 ms65016 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back using namespace std; const int N = 1e5 + 55; int days, delay, number_jobs; vector<pair<ll, ll>> jobs; vector<ll> ans[N]; bool check(ll machine) { for(int i=0; i<days; i++) { ans[i].clear(); } ll id_job = 0; for(int i=0; i<days; i++) { int cur_machine = 0; while(cur_machine < machine) { if (id_job == number_jobs) break; if (jobs[id_job].fi <= delay + i + 1) { ans[i].pb(jobs[id_job].se); id_job++, cur_machine++; } else break; } } return (id_job == number_jobs); } ll bs(ll l, ll r) { while(l < r) { ll m = (l + r) >> 1; if (check(m)) { r = m; } else { l = m + 1; } } check(l); return l; } void solve() { cin >> days >> delay >> number_jobs; for(int i=0; i<number_jobs; i++) { ll x; cin >> x; jobs.pb({x, i + 1}); } sort(jobs.begin(), jobs.end()); cout << bs(1, days) << "\n"; for(int i=0; i<days; i++) { ans[i].pb(0); } for(int i=0; i<days; i++) { for(int j=0; j<(int)ans[i].size(); j++) { cout << ans[i][j] << " "; } cout << "\n"; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...