# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085564 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++17 | 283 ms | 17088 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,m,k;
vector<int>v[100001];
bool check(int x)
{
int t=v[1].size(),l=1;
for(int i=1;i<=k;i++)
{
int temp=x;
if(l+m<i)
{
return false;
}
while(l<=i)
{
if(t<=temp)
{
l++;
temp-=t;
t=v[l].size();
}
else
{
t-=temp;
break;
}
}
}
if(l!=k+1)
{
return false;
}
return true;
}
int main()
{
int a;
cin>>k>>m>>n;
for(int i=0;i<n;i++)
{
cin>>a;
v[a].push_back(i+1);
}
int l=1,r=k;
while(l<r)
{
int mid=(l+r)/2;
if(check(mid))
{
r=mid;
}
else
{
l=mid+1;
}
}
cout<<r<<endl;
l=1;
int t=v[1].size(),lx=0;
for(int i=1;i<=k;i++)
{
int temp=r;
while(l<=i)
{
if(t<=temp)
{
for(int j=lx;j<v[l].size();j++)
{
cout<<v[l][j]<<" ";
}
l++;
lx=0;
temp-=t;
t=v[l].size();
}
else
{
for(int j=lx;j<lx+temp;j++)
{
cout<<v[l][j]<<" ";
}
lx+=temp;
t-=temp;
break;
}
}
cout<<"0"<<endl;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |