# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
507546 | Christopher_ | Job Scheduling (CEOI12_jobs) | C++17 | 232 ms | 14592 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.
/**
* author: lani
* created: 12.01.2022 20:57:54
**/
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "debug.hpp"
#else
#define dbg(...) void(37)
#endif
int main() {
ios::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;
}
sort(a.begin(), a.end());
auto Check = [&](int k) {
dbg(k);
int day = 1, work = 0;
for (int i = 0; i < m; ++i) {
if (a[i].first + d < day) {
return false;
} else {
++work;
}
if (work >= k) {
work = 0;
++day;
}
}
return true;
};
int ans = 1e6;
int low = 0, high = (int) 1e6;
while (low <= high) {
int mid = (low + high) >> 1;
if (Check(mid)) {
high = mid - 1;
ans = mid;
} else {
low = mid + 1;
}
}
cout << ans << '\n';
dbg();
int day = 1, work = 0;
for (int i = 0; i < m; ++i) {
if (work == ans) {
cout << "0\n";
++day;
work = 1;
cout << a[i].second + 1 << ' ';
} else {
cout << a[i].second + 1 << ' ';
++work;
}
}
dbg(ans);
if (m % ans) {
cout << "0\n";
}
dbg();
for (; day <= n; ++day) {
cout << "0\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |