# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
882375 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++14 | 206 ms | 25080 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define _for(i, a, b) for(LL i = (a); i <= (b); ++i)
using LL = long long;
const int MM = 1E6 + 5, NN = 1E5 + 5;
LL n, m, d, D[MM];
vector<LL> B[NN];
bool wk(LL x, LL op){//op为0则不输出方案,op为1则输出方案
queue<array<LL, 2>> Q;
_for(i, 1, n){
LL 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(LL 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);
LL 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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |