# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
958292 | JwFXoiz | Job Scheduling (CEOI12_jobs) | C++14 | 283 ms | 21416 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;
#define int long long
#define inf 0x3F3F3F3F
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
vector<int> v[n + 1];
for (int i = 1; i <= m; i++)
{
int x;
cin >> x;
v[x].push_back(i);
}
int l = 1, r = m;
while (l < r)
{
int mid = (l + r) >> 1;
queue<array<int, 2>> q;
int ok = 1;
for (int i = 1; i <= n; i++)
{
for (int x : v[i]) q.push({x, i});
int k = mid;
while (!q.empty() && k--) q.pop();
if (!q.empty() && q.front()[1] + d == i)
{
ok = 0;
break;
}
}
ok &= q.empty();
if (ok) r = mid;
else l = mid + 1;
}
cout << l << '\n';
queue<array<int, 2>> q;
for (int i = 1; i <= n; i++)
{
for (int x : v[i]) q.push({x, i});
int k = l;
while (!q.empty() && k--)
{
cout << q.front()[0] << ' ';
q.pop();
}
cout << 0 << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |