# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
405021 | aaravdodhia | Job Scheduling (CEOI12_jobs) | C++17 | 646 ms | 38196 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, d, m;
vector<pair<int,int>> A;
vector<vector<int>> schedule;
bool works(int machines){
for(int i=0; i<n; ++i) schedule[i].clear();
int task = 0;
for(int day = 0; day < n && task < m; task++){
if(day > A[task].first + d){
return false;
}
schedule[day].push_back(A[task].second);
if(schedule[day].size() == machines){
day++;
}
}
return task == m; // dod we complete all m tasks within n days?
}
int main()
{
cin >> n >> d >> m;
A.resize(m);
schedule.resize(n);
for(int i=0; i<m; i++){
cin >> A[i].first;
A[i].second = i+1;
}
sort(begin(A), end(A));
int lo = 1, hi = m;
while(lo < hi){
int mc = lo + (hi - lo)/2;
if(works(mc)){
hi = mc;
} else{
lo = mc + 1;
}
}
if(works(lo)) cout << lo << '\n';
for(vector<int> day: schedule){
for(int task: day){
cout << task << ' ';
}
cout << 0 << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |