# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
667037 | hanlei35 | Job Scheduling (CEOI12_jobs) | C++17 | 365 ms | 13900 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int N, D, M;
pair<int,int> jobs[1000005];
bool check(int m){
int maxD = -1;
int j = -1;
for(int i=0;i<N;i++){
int count = 0;
while(count!=m&&j!=M-1&&jobs[j+1].first<=i+1){
maxD = max(maxD,i+1-jobs[++j].first);
count++;
}
}
if(maxD > D) return true;
return false;
}
int search(){
int ans = 0;
for(int val = M; val >= 1; val /= 2){
while(ans+val <= M && check(ans+val)) ans += val;
}
return ans + 1;
}
int main(){
cin >> N >> D >> M;
for(int i=0;i<M;i++){
cin >> jobs[i].first;
jobs[i].second = i+1;
}
sort(jobs,jobs+M);
int minM = search();
cout << minM << "\n";
int j = -1;
for(int i=0;i<N;i++){
int count = 0;
while(count!=minM&&j!=M-1&&jobs[j+1].first<=i+1){
cout << jobs[++j].second << " ";
count++;
}
cout << "0\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |