# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1046644 | mtshasta | Job Scheduling (CEOI12_jobs) | C++17 | 156 ms | 19676 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;
typedef long long ll;
void solve() {
int n, d, m;
cin >> n >> d >> m;
vector<int> jobs(m), o(m);
vector<vector<int>> res(n);
for (int i = 0; i < m; ++i) {
cin >> jobs[i];
--jobs[i];
}
iota(o.begin(), o.end(), 0);
sort(o.begin(), o.end(), [&](int i, int j) { return jobs[i] < jobs[j]; });
auto ok = [&](int mach) -> bool {
int id = 0;
for (int i = 0; i < n; ++i) {
int cnt = 0;
while (id < m && jobs[o[id]] <= i + d && cnt < mach) {
++id;
++cnt;
}
}
return id == m;
};
int l = 1, r = 1e6, ans;
while (l <= r) {
int mid = l + (r - l) / 2;
if (!ok(mid))
l = mid + 1;
else {
ans = mid;
r = mid - 1;
}
}
cout << ans << '\n';
int id = 0;
for (int i = 0; i < n; ++i) {
int cnt = 0;
while (id < m && jobs[o[id]] <= i + d && cnt < ans) {
cout << o[id] + 1 << ' ';
++id;
++cnt;
}
cout << 0 << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |