# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
550360 | FromDihPout | Job Scheduling (CEOI12_jobs) | C++17 | 257 ms | 23640 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* author: FromDihPout
* created: 2022-04-17
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
vector<pair<int, int>> a(m);
for (int i = 0; i < m; i++) {
cin >> a[i].first;
a[i].second = i + 1;
}
sort(a.begin(), a.end());
auto check = [&](int x) {
int day = 1, cnt = 0;
for (int i = 0; i < m; i++) {
if (day < a[i].first || cnt >= x) {
day = max(day + 1, a[i].first);
cnt = 0;
}
if (day - a[i].first > d) {
return false;
}
cnt += 1;
}
return day <= n;
};
int l = 1, r = m;
int machines = r;
while (l <= r) {
int mid = (l + r) / 2;
if (check(mid)) {
machines = mid;
r = mid - 1;
} else {
l = mid + 1;
}
}
int day = 0;
vector<vector<int>> res;
for (int i = 0; i < m; i++) {
while (a[i].first > day || res.back().size() >= machines) {
res.push_back({});
day++;
}
res.back().push_back(a[i].second);
}
while (day < n) {
res.push_back({});
day++;
}
cout << machines << '\n';
for (int i = 0; i < n; i++) {
for (int id : res[i]) {
cout << id << ' ';
}
cout << '0' << '\n';
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |