# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62687 | eriksuenderhauf | Job Scheduling (CEOI12_jobs) | C++11 | 564 ms | 33792 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.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define enl printf("\n")
#define ni(n) scanf("%d", &(n))
#define pri(n) printf("%d\n", (n))
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
using namespace std;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 50;
pii a[MAXN];
vi ans[MAXN / 10];
int n, m, d, vis[MAXN];
bool ok(int mi)
{
int r = 1;
for (int i = 1; i <= n; i++)
{
int tmp = min(m - r + 1, mi);
for (int j = 0; j < mi && j + r <= m; j++)
{
if (a[j + r].fi + d < i)
return false;
if (a[j + r].fi > i)
{
tmp = j;
break;
}
}
r += tmp;
}
if (r < m)
return false;
return true;
}
int main()
{
ni(n), ni(d), ni(m);
for (int i = 1; i <= m; i++)
ni(a[i].fi), a[i].se = i;
sort(a + 1, a + m + 1);
int lo = 1, hi = m, ans2 = INF;
while (lo <= hi)
{
int mi = (lo + hi) / 2;
if (ok(mi))
hi = mi - 1, ans2 = min(mi, ans2);
else
lo = mi + 1;
}
int r = 1;
for (int i = 1; i <= n; i++)
{
int tmp = min(m - r + 1, ans2);
for (int j = 0; j < ans2 && j + r <= m; j++)
{
if (a[j + r].fi > i)
{
tmp = j;
break;
}
ans[i].pb(a[j + r].se);
}
r += tmp;
}
pri(ans2);
for (int i = 1; i <= n; i++, printf("0\n"))
for (int j: ans[i])
{
if (vis[j])
continue;
vis[j] = 1;
printf("%d ", j);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |