# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
438303 | horsefeedapples | Job Scheduling (CEOI12_jobs) | C++17 | 685 ms | 20104 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MXN = 1e5+5;
int N, D, M;
vector<pair<int,int>> jobs; // day, index
vector<int> ans[MXN];
bool check(int machines){
// Filled[i] represents how many tasks are processed on day i
vector<int> filled(MXN, 0);
int currDay = 0;
for(int i=0; i<M; i++){
currDay = max(currDay, jobs[i].first);
if(filled[currDay]>=machines) currDay++; // try if(filled[head]>=x)
if(currDay>jobs[i].first+D) return false;
filled[currDay]++;
}
return true;
}
int firstTrue(int lo, int hi) {
for (hi ++; lo < hi; ) {
int mid = lo+(hi-lo)/2;
if (check(mid)) hi = mid;
else lo = mid+1;
}
return lo;
}
int main(){
cin>>N>>D>>M;
for(int i=0; i<M; i++){
int x; cin>>x;
jobs.push_back({x, i+1});
}
sort(jobs.begin(), jobs.end());
int numMachines = firstTrue(0, MXN);
cout<<numMachines<<endl;
int currDay = 0;
for(int i=0; i<M; i++){
currDay = max(currDay, jobs[i].first);
if(ans[currDay].size()>=numMachines) currDay++;
ans[currDay].push_back(jobs[i].second);
}
for(int i=1; i<=N; i++){
for(int j=0; j<ans[i].size(); j++){
cout<<ans[i][j]<<" ";
}
cout<<0<<endl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |