| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 692571 | Snowmanonahoe | Job Scheduling (CEOI12_jobs) | C++17 | 380 ms | 20208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> jobs;
int N, M, D;
optional<vector<vector<int>>> check(int num) {
vector<vector<int>> schedule(N+1);
queue<pair<int, int>> jobQueue;
for (int i = 1, j = 1; i <= N; i++) {
while (j <= M && jobs[j].first == i) {
jobQueue.push(jobs[j]);
j++;
}
for (int k = 0; k < num && !jobQueue.empty(); k++) {
if (jobQueue.front().first + D < i)
return nullopt;
schedule[i].push_back(jobQueue.front().second);
jobQueue.pop();
}
}
if (jobQueue.empty())
return schedule;
return nullopt;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> D >> M;
jobs.resize(M+1);
for (int i = 1; i <= M; i++) {
cin >> jobs[i].first;
jobs[i].second = i;
}
sort(jobs.begin()+1, jobs.end());
int l = 1, r = M;
while (l < r) {
int mid = (l + r) / 2;
if (check(mid))
r = mid;
else
l = mid + 1;
}
cout << l << '\n';
auto ans = *check(l);
for (int i = 1; i <= N; i++) {
for (auto j : ans[i])
cout << j << ' ';
cout << "0\n";
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
