제출 #1087578

#제출 시각아이디문제언어결과실행 시간메모리
1087578Rafael_AugustoJob Scheduling (CEOI12_jobs)C++17
95 / 100
547 ms19220 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define dbg(v) cerr << #v << " = " << v << "\n" #define fall(i, n) for(int i=0; i<n; i++) typedef long long ll; typedef pair<int, int> pii; int n, d, m; vector<pii> v; bool f(int c){ int id=c; priority_queue<int, vector<int>, greater<int>> pq; fall(i, c) pq.push(v[i].f); while(id < m){ int t = pq.top()+1; if(t - v[id].f > d) return 0; pq.pop(), pq.push(t), id++; } return 1; } int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n >> d >> m; v=vector<pii>(m); fall(i, m){ cin >> v[i].f; v[i].s = i+1; } sort(v.begin(), v.end()); int ini=1, fim = m; while(ini < fim){ ll mid = (ini+fim)/2; if(f(mid)) fim = mid; else ini = mid+1; } cout << fim << "\n"; int id=0; fall(i, n){ for(int mc=fim+id; id<mc && id<m && v[id].f <= i+1; id++) cout << v[id].s << " "; cout << "0\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...