# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
416227 | iulia13 | Job Scheduling (CEOI12_jobs) | C++14 | 490 ms | 26708 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 <algorithm>
#include <vector>
using namespace std;
const int M = 1e6 + 6;
const int N = 1e5 + 5;
pair <int, int> v[M];
vector <int> ans[N];
int main()
{
int n, d, m, i;
cin >> n >> d >> m;
for (i = 1; i <= m; i++)
{
cin >> v[i].first;
v[i].second = i;
}
sort(v + 1, v + m + 1);
int st = 1, dr = m, sol;
while (st <= dr)
{
int mid = (st + dr) / 2;
int bad = 0, day = 1;
i = 1;
while (i <= m && !bad)
{
int c = 0;
while (!bad && c < mid && day >= v[i].first && i <= m)
{
if (v[i].first + d < day)
bad = 1;
c++;
i++;
}
day++;
}
if (i <= m || bad)
st = mid + 1;
else
{
sol = mid;
dr = mid - 1;
}
}
cout << sol;
int day = 1;
i = 1;
while (i <= m)
{
int c = 0;
while (c < sol && day >= v[i].first && i <= m)
{
ans[day].push_back(v[i].second);
c++;
i++;
}
ans[day].push_back(0);
day++;
}
while (day <= n)
{
ans[day].push_back(0);
day++;
}
for (i = 1; i <= n; i++)
{
cout << '\n';
for (int j = 0; j < ans[i].size(); j++)
cout << ans[i][j] << " ";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |