# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1082215 | galaxy_kitty | Job Scheduling (CEOI12_jobs) | C++17 | 240 ms | 17492 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 <utility>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main()
{
int n, d, m;
cin >> n >> d >> m;
int day[100000] = {};
vector<int> arr[n];
for (int i = 0; i < m; i++)
{
int a;
cin >> a;
day[a - 1]++;
arr[a - 1].push_back(i + 1);
}
int l = 0, r = m, mid = (l + r + 1) / 2;
while (l < r)
{
set<pair<int, int>> q;
bool f = true;
for (int i = 0; i < n; i++)
{
if (day[i] != 0)
{
q.insert({i, day[i]});
}
int a = mid;
while (a > 0 && q.begin() != q.end())
{
int b = min(a, (*q.begin()).second);
q.insert({(*q.begin()).first, (*q.begin()).second - b});
q.erase(++q.begin());
a -= b;
if ((*q.begin()).second == 0)
{
q.erase(q.begin());
}
}
if (q.begin() != q.end() && i - (*q.begin()).first == d)
{
f = false;
break;
}
}
if (f)
{
r = mid - 1;
mid = (l + r + 1) / 2;
}
else
{
l = mid;
mid = (l + r + 1) / 2;
}
}
mid++;
cout << mid << "\n";
set<pair<int, int>> q;
for (int i = 0; i < n; i++)
{
for (auto a : arr[i])
{
q.insert({i, a});
}
for (int a = 0; (a < mid && q.begin() != q.end()); a++)
{
cout << (*q.begin()).second << " ";
q.erase(q.begin());
}
cout << 0 << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |