# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087562 | Rafael_Augusto | Job Scheduling (CEOI12_jobs) | C++17 | 3008 ms | 65536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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+j >= 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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |