# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
709906 | groshi | Job Scheduling (CEOI12_jobs) | C++17 | 357 ms | 17208 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<vector>
#include<algorithm>
#include<queue>
using namespace std;
vector<pair<int,int> > Q;
int n,d,m;
void wypisz(int x)
{
cout<<x<<"\n";
queue<pair<int,int> > kolejka;
bool git=1;
int gdzie=0;
for(int i=1;i<=n;i++)
{
while(gdzie<Q.size() && Q[gdzie].first==i)
{
kolejka.push(Q[gdzie]);
gdzie++;
}
for(int j=1;j<=x;j++)
{
if(kolejka.size()==0)
break;
int kiedy=kolejka.front().first;
cout<<kolejka.front().second<<" ";
kolejka.pop();
}
cout<<"0\n";
}
}
bool git(int x)
{
queue<pair<int,int> > kolejka;
bool git=1;
int gdzie=0;
for(int i=1;i<=n;i++)
{
while(gdzie<Q.size() && Q[gdzie].first==i)
{
kolejka.push(Q[gdzie]);
gdzie++;
}
for(int j=1;j<=x;j++)
{
if(kolejka.size()==0)
break;
int kiedy=kolejka.front().first;
if(kiedy+d<i)
{
git=0;
break;
}
kolejka.pop();
}
if(git==0)
break;
}
if(git && kolejka.size()==0)
return 1;
else return 0;
}
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int x;
cin>>n>>d>>m;
for(int i=1;i<=m;i++)
{
cin>>x;
Q.push_back({x,i});
}
sort(Q.begin(),Q.end());
int pocz=1,kon=m+1,sre,ostd;
while(pocz<kon)
{
sre=(pocz+kon)/2;
if(git(sre))
{
ostd=sre;
kon=sre;
}
else pocz=sre+1;
}
wypisz(ostd);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |