# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
699000 | nguyennehehe | Job Scheduling (CEOI12_jobs) | C++14 | 33 ms | 7264 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;
const int N = 1e5 + 1;
int n, d, m;
pair<int, int> a[N];
vector<int> ans[N];
bool good(int k) {
int j = 1;
for (int i = 1; i <= n; ++i) {
for (int x = 1; x <= k; ++x) {
if (a[j].first > i) break;
if (a[j].first + d < i) return false;
if (j == m) return true;
++j;
}
}
return false;
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> d >> m;
for (int i = 1; i <= m; ++i) {
cin >> a[i].first;
a[i].second = i;
}
sort(a + 1, a + 1 + m);
int l = 0, r = m + 1;
while (r - l > 1) {
int mid = (l + r) >> 1;
if (good(mid)) r = mid;
else l = mid;
}
cout << r << '\n';
for (int i = 1, j = 1; i <= n; ++i) {
for (int x = 1; x <= r; ++x) {
if (a[j].first > i) break;
if (a[j].first + d >= i) ans[i].push_back(a[j++].second);
}
for (int k: ans[i]) cout << k << ' ';
cout << "0\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |