# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260065 | MiricaMatei | Job Scheduling (CEOI12_jobs) | C++17 | 355 ms | 17272 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;
const int MAXN = 100005;
const int MAXM = 1000005;
pair<int, int> v[MAXM];
bool ok(int n, int d, int m, int k) {
int j = 1;
for (int i = 1; i <= n; ++i) {
int k1 = k;
while (j <= m && v[j].first <= i && k1 > 0) {
if (i - v[j].first > d)
return 0;
j++;
k1--;
}
}
return 1;
}
int main() {
//freopen("date.in", "r", stdin);
//freopen("date.out", "w", stdout);
int n, d, m;
scanf("%d%d%d", &n, &d, &m);
for (int i = 1; i <= m; ++i) {
scanf("%d", &v[i].first);
v[i].second = i;
}
sort(v + 1, v + m + 1);
int ans = 0;
for (int i = 19; i >= 0; --i)
if (ans + (1 << i) < m && !ok(n, d, m, ans + (1 << i)))
ans += (1 << i);
printf("%d\n", ans + 1);
int k = ans + 1, j = 1;
for (int i = 1; i <= n; ++i) {
int k1 = k;
while (j <= m && v[j].first <= i && k1 > 0) {
printf("%d ", v[j].second);
if (i - v[j].first > d)
return 0;
j++;
k1--;
}
printf("0\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |