# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
571546 | Lextyle | Job Scheduling (CEOI12_jobs) | C++17 | 279 ms | 23512 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>
#pragma warning(disable : 4996)
#pragma warning(disable : 6031)
#define USACO freopen("haybales.in", "r", stdin); freopen("haybales.out", "w+", stdout);
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
pair<int, int> a[1000000];
vector<int> ans[100000];
bool check(int n, int cnt, int d, int m)
{
int l = 0;
for (int i = 1; i <= n; i++)
{
ans[i - 1].clear();
if (l < m && i - a[l].first > d)
{
return 0;
}
int cnt2 = 0;
while (cnt2 < cnt && l < m && a[l].first <= i)
{
ans[i - 1].push_back(a[l].second);
l++;
cnt2++;
}
}
return 1;
}
int main()
{
//USACO
fastIO;
int n, d, m;
cin >> n >> d >> m;
for (int i = 0; i < m; i++)
{
cin >> a[i].first;
a[i].second = i + 1;
}
sort(a, a + m);
int l = 1, r = m;
while (l < r)
{
int mid = l + (r - l) / 2;
if (check(n, mid, d, m))
{
r = mid;
}
else
{
l = mid + 1;
}
}
check(n, l, d, m);
cout << l << "\n";
for (int i = 0; i < n; i++)
{
for (int j = 0; j < ans[i].size(); j++)
{
cout << ans[i][j] << " ";
}
cout << "0\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |