# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
650832 | borisAngelov | Job Scheduling (CEOI12_jobs) | C++11 | 434 ms | 26184 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 100005;
int n, m, d;
vector<pair<int, int>> jobs;
pair<bool, vector<vector<int>>> check(int machines) {
vector<vector<int>> schedule;
schedule.resize(n + 1);
int currJob = 0;
for (int day = 1; day <= n; day++) {
for (int j = 0; j < machines; j++) {
if (jobs[currJob].first > day) break;
if (jobs[currJob].first + d >= day) {
schedule[day].push_back({jobs[currJob++].second});
} else {
return {false, schedule};
}
if (currJob == m) {
return {true, schedule};
}
}
}
return {false, schedule};
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> d >> m;
for (int i = 1; i <= m; i++) {
int day; cin >> day;
jobs.push_back({day, i});
}
sort(jobs.begin(), jobs.end());
int l = 1;
int r = m;
while (l <= r) {
int mid = (l + r) / 2;
if (check(mid).first) r = mid - 1;
else l = mid + 1;
}
cout << l << "\n";
vector<vector<int>> schedule = check(l).second;
for (int i = 1; i <= n; i++) schedule[i].push_back(0);
for (int i = 1; i <= n; i++) {
cout << schedule[i][0];
for (int j = 1; j < schedule[i].size(); j++) cout << " " << schedule[i][j];
cout << "\n";
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |