# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
693451 | ojuzuser12 | Job Scheduling (CEOI12_jobs) | C++17 | 223 ms | 13712 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() {
ios::sync_with_stdio(false);
cin.tie(0);
long long N, D, M; cin >> N >> D >> M;
vector<pair<int, int>> jobs(M);
for(int i = 0; i < M; i++) {
cin >> jobs[i].first;
jobs[i].second = i;
}
sort(jobs.begin(), jobs.end());
long long l = 1, r = M, mid;
while(l < r) {
mid = (l + r) / 2;
bool works = ((M + mid - 1) / mid <= N);
for(long long d = 0; d < min((M + mid - 1) / mid, N); d++) {
for(long long i = d * mid; i < min(M, (d + 1) * mid); i++) {
if(d + 1 - jobs[i].first > D) {
works = false;
break;
}
}
if(!works) break;
}
if(works) {
r = mid;
} else {
l = mid + 1;
}
}
cout << r << '\n';
for(long long d = 0; d < N; d++) {
for(long long i = (long long) d * r; i < min((long long) M, (long long) (d + 1) * r); i++) {
cout << jobs[i].second + 1 << ' ';
}
cout << 0 << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |