# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
715685 | 12345678 | Job Scheduling (CEOI12_jobs) | C++17 | 154 ms | 16688 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;
int N, D, M, d;
vector<vector<int>> v(100005);
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>N>>D>>M;
for (int i=1; i<=M; i++)
{
cin>>d;
v[d].push_back(i);
}
int l=1, r=M;
while (l<r)
{
int md=(l+r)/2;
bool can=true;
deque<pair<int, int>> dq;
for (int i=1; i<=N; i++)
{
if (v[i].size()!=0)
dq.push_back({i+D, v[i].size()});
int mc=md;
while (mc>0&&!dq.empty())
{
int cw=dq.front().second;
if (mc>=cw)
{
mc-=cw;
dq.pop_front();
}
else
{
int dl=dq.front().first;
dq.pop_front();
dq.push_front({dl, cw-mc});
mc=0;
break;
}
}
if (!dq.empty())
{
if (dq.front().first<=i)
{
can=false;
break;
}
}
}
if (can)
r=md;
else
l=md+1;
}
cout<<l<<'\n';
queue<int> q;
for (int i=1; i<=N; i++)
{
int left=l;
for (auto a:v[i])
q.push(a);
while (!q.empty()&&left>0)
{
left--;
cout<<q.front()<<' ';
q.pop();
}
cout<<"0\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |