# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
637895 | SeyedAmirHs | Job Scheduling (CEOI12_jobs) | C++17 | 183 ms | 18524 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
vector<vector<int>> works_in_day(n);
for (int i = 0; i < m; i++) {
int x;
cin >> x;
x--;
works_in_day[x].push_back(i);
}
auto can = [&](int y) -> bool {
int day = 0;
queue<int> q;
while (day < n) {
for (auto &x : works_in_day[day]) {
q.push(day + d);
}
int cnt = 0;
while (cnt < y and !q.empty()) {
if (day >= q.front()) {
return false;
}
q.pop();
cnt++;
}
day++;
}
return q.empty();
};
int l = 0, r = n;
while (r - l > 1) {
int mid = l + (r - l) / 2;
if (can(mid)) {
r = mid;
} else {
l = mid;
}
}
int need = r;
queue<int> q;
cout << need << '\n';
for (int i = 0; i < n; i++) {
for (auto &x : works_in_day[i]) {
q.push(x);
}
int cnt = 0;
while (cnt < need and !q.empty()) {
cout << q.front() + 1 << ' ';
q.pop();
cnt++;
}
cout << 0 << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |