# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1075165 | inkvizytor | Job Scheduling (CEOI12_jobs) | C++17 | 105 ms | 21180 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_base::sync_with_stdio(0);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
vector<int> v (n+1, 0), sp (n+1, 0);
vector<vector<int>> c (n+1);
for (int i = 1; i < m+1; i++) {
int x;
cin >> x;
v[x]++;
c[x].push_back(i);
}
vector<int> s;
for (auto i : c) {
for (int x : i) {
s.push_back(x);
}
}
for (int i = 1; i < n+1; i++) {
sp[i] = sp[i-1]+v[i];
}
int p = 0, j = 1<<20;
while (j > 0) {
int k = p+j;
int wyk = 0;
bool b = 1;
for (int i = 1; i < n+1; i++) {
wyk = min(wyk+k, sp[i]);
if (i > d+1 && wyk < sp[i-d-1]) {
b = 0;
break;
}
}
if (!b) {
p += j;
}
j /= 2;
}
cout << p+1 << '\n';
int k = p+1, nr = 0;
int wyk = 0;
for (int i = 1; i < n+1; i++) {
wyk = min(wyk+k, sp[i]);
while (nr < wyk) {
cout << s[nr] << ' ';
nr++;
}
//cout << "0\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |