# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029510 | ArthuroWich | Job Scheduling (CEOI12_jobs) | C++17 | 363 ms | 21460 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;
bool check(vector<int> a, int mi, int n, int d) {
int i = 1;
while(a.size() && i <= n) {
for (int j = 0; j < mi; j++) {
if (a.empty()) {
break;
}
if (i > a.back()+d) {
return 0;
}
a.pop_back();
}
i++;
}
return a.size() == 0;
}
void solve() {
int n, d, m;
cin >> n >> d >> m;
vector<int> a(m);
vector<pair<int, int>> ans;
for (int i = 0; i < m; i++) {
cin >> a[i];
ans.push_back({a[i], i});
}
sort(a.rbegin(), a.rend());
sort(ans.begin(), ans.end());
int l = 1, r = n;
while(l < r) {
int mi = (l+r)/2;
if (check(a, mi, n, d)) {
r = mi;
} else {
l = mi+1;
}
}
cout << l << endl;
int j = 0;
for (int i = 0; i < n; i++) {
int c = l;
while(j < m && c--) {
cout << ans[j].second+1 << " ";
j++;
}
cout << 0 << endl;
}
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
t = 1;
while(t--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |