# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
542210 | jakubd | Job Scheduling (CEOI12_jobs) | C++17 | 483 ms | 30296 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false); 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());
vector<vector<int>> res;
int lo = 1, hi = m;
while (lo < hi) {
int mi = (lo + hi) / 2;
vector<vector<int>> cur(n + 1);
queue<int> q; for (int i = 0; i < mi; i++) q.push(0);
bool ok = true;
for (int i = 0; i < m; i++) {
if (q.front() - d <= a[i].first) {
int nv = max(a[i].first, q.front()); q.pop();
q.push(nv + 1);
cur[nv].push_back(a[i].second);
} else {
ok = false;
break;
}
}
if (ok) {
hi = mi;
res = cur;
} else {
lo = mi + 1;
}
}
cout << lo << "\n";
for (int i = 1; i <= n; i++) {
for (int x : res[i]) cout << x << " ";
cout << "0\n";
}
return 0;
};
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |