# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104879 | daili | Job Scheduling (CEOI12_jobs) | C++14 | 352 ms | 14028 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;
bool check(int x, int n, vector<pair<int,int>> &allJobs, bool finall, int m, int d)
{
int ptr = 1;
for(int i = 1; i <= n;i++)
{
int ct = 0;
while(ptr <= m && allJobs[ptr].first <= i && ct < x)
{
if(allJobs[ptr].first + d >= i)
{
ptr++;
}
else
{
return false;
}
if(finall)
{
cout << allJobs[ptr-1].second << " ";
}
ct++;
}
if(finall)
{
cout << 0 << "\n";
}
}
if(ptr <= m)
{
return false;
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
vector<pair<int,int>> allJobs;
allJobs.push_back({0, 0});
for (int i = 0; i < m; i++)
{
int x;
cin >> x;
allJobs.push_back({x, i+1});
}
sort(allJobs.begin(), allJobs.end());
int left = 1;
int right = m;
while(left < right)
{
int mid = (left + right) >> 1;
if (check(mid, n, allJobs, 0, m, d))
{
right = mid;
}
else
{
left = mid + 1;
}
}
cout << left << "\n";
auto z = check(left, n, allJobs, 1, m, d);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |