# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
515775 | mzh | Job Scheduling (CEOI12_jobs) | C++17 | 199 ms | 15624 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef LOCAL
freopen("input.in", "r", stdin);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, d, m;
cin >> n >> d >> m;
vector<pair<int, int>> t(m);
for (int i = 0; i < m; i++) {
cin >> t[i].first;
t[i].second = i + 1;
}
sort(t.begin(), t.end());
vector<vector<int>> res;
int l = 0, r = m;
while (l + 1 < r) {
int mid = l + (r - l) / 2;
vector<vector<int>> cur(n + 1);
queue<int> q;
for (int i = 0; i < mid; i++) {
q.push(0);
}
bool ok = true;
for (int i = 0; i < n; i++) {
if (q.front() - d <= t[i].first) {
int jt = max(q.front(), t[i].first);
q.push(jt + 1);
cur[jt].push_back(t[i].second);
q.pop();
} else {
ok = false;
break;
}
}
if (ok) {
r = mid;
res = cur;
} else {
l = mid;
}
}
cout << r << '\n';
for (int i = 1; i <= n; i++) {
for (int x : res[i]) {
cout << x << ' ';
}
cout << "0\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |