# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
623539 | binisgiannis | Job Scheduling (CEOI12_jobs) | C++17 | 274 ms | 13744 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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> pi;
#define x first
#define y second
int N, D, M; vector<pi> vec;
bool f(int &x) {
int index = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < x; j++) {
if (vec[index].x > (i+1)) break;
if ((i+1) - vec[index].x > D) return false;
index++;
if (index >= M) goto endofloop;
}
}
endofloop:
return index >= M;
}
void res(int &x) {
int index = 0, counter = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < x; j++) {
if (index < M) {
cout << vec[index].y << ' ';
index++;
}
}
cout << 0 << '\n';
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> N >> D >> M;
vec.resize(M);
for (int i = 0; i < M; i++) {
cin >> vec[i].x;
vec[i].y = i+1;
}
sort(vec.begin(), vec.end());
int l = 1, r = M, mid;
while (l < r) {
mid = (l+r)/2;
if (!f(mid)) l = mid+1;
else {
r = mid;
}
}
cout << l << '\n';
res(l);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |