# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
225792 | Andrei_Cotor | Job Scheduling (CEOI12_jobs) | C++11 | 331 ms | 27000 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<deque>
#include<vector>
using namespace std;
vector<int> Jobs[100005];
vector<int> Rez[100005];
int Day[1000005];
int n,d;
bool possible(int capacity)
{
deque<int> Pending;
for(int i=1; i<=n; i++)
{
Rez[i].clear();
for(auto job:Jobs[i])
Pending.push_back(job);
for(int j=1; j<=capacity; j++)
{
if(Pending.empty())
break;
if(i-Day[Pending.front()]>d)
return 0;
Rez[i].push_back(Pending.front());
Pending.pop_front();
}
}
if(!Pending.empty())
return 0;
return 1;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int m;
cin>>n>>d>>m;
for(int i=1; i<=m; i++)
{
int x;
cin>>x;
Jobs[x].push_back(i);
Day[i]=x;
}
int rez=0;
for(int i=19; i>=0; i--)
{
if(!possible(rez+(1<<i)))
rez+=(1<<i);
}
rez++;
cout<<rez<<"\n";
possible(rez);
for(int i=1; i<=n; i++)
{
for(auto task:Rez[i])
cout<<task<<" ";
cout<<"0\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |