# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
880488 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++14 | 198 ms | 16980 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 _for(i, a, b) for(int i = (a); i <= (b); ++i)
const int MM = 1E6 + 5, NN = 1E5 + 5;
int n, m, d, D[MM];
vector<int> B[NN];
bool wk(int x, int op){//op为0则不输出方案,op为1则输出方案
queue<array<int, 2>> Q;
_for(i, 1, n){
int t = x;
while(!Q.empty() && t){
auto f = Q.front();
if(f[1] + d < i) return 0;
if(op == 1) printf("%d ", f[0]);
Q.pop(), --t;
}
if(!Q.empty() && Q.front()[1] + d < i) return 0;
for(int j = 0; j < B[i].size(); ++j)
if(t && (--t, op == 1)) printf("%d ", B[i][j]);
else Q.push({B[i][j], i});
if(op == 1) puts("0");
}
return 1;
}
int main() {
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> d >> m;
_for(i, 1, m) cin >> D[i], B[D[i]].push_back(i);
int l = 1, r = m, mid;
while(l <= r) (wk(mid = l + r >> 1, 0) ? r = mid - 1 : l = mid + 1);
return printf("%d\n", r + 1), wk(r + 1, 1), 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |