# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
102158 | thebes | Job Scheduling (CEOI12_jobs) | C++14 | 456 ms | 20348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MN = 1e5+5;
int N, D, M, i, x, lo, hi, src[10*MN];
vector<int> adj[MN];
queue<int> q;
bool check(int m){
while(q.size()) q.pop();
for(int i=1;i<=N;i++){
for(auto v : adj[i]) q.push(v);
int sz = min((int)q.size(), m);
while(sz--){
if(src[q.front()]+D-1<i) return 0;
q.pop();
}
}
return q.size()==0;
}
int main(){
for(scanf("%d%d%d",&N,&D,&M),i=1;i<=M;i++)
scanf("%d",&x), adj[x].push_back(i), src[i]=x;
lo = 1, hi = M;
while(lo<hi){
int m = lo+hi>>1;
if(check(m)) hi=m;
else lo=m+1;
}
printf("%d\n",lo);
while(q.size()) q.pop();
for(i=1;i<=N;i++){
for(auto v: adj[i]) q.push(v);
int sz = min((int)q.size(), lo);
while(sz--){
printf("%d ",q.front());
q.pop();
}
printf("0\n");
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |