Submission #1087561

#TimeUsernameProblemLanguageResultExecution timeMemory
1087561Rafael_AugustoJob Scheduling (CEOI12_jobs)C++17
50 / 100
527 ms28184 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){ fall(j, fim){ if(id >= m) break; if(v[id+j].f <= i+1) cout << v[id+j].s << " "; else{ id+=j; break;} if(j == fim-1) id += fim; } cout << "0\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...