# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062290 | Kiet07 | Job Scheduling (CEOI12_jobs) | C++14 | 1048 ms | 65536 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,d;
bool check(int x,multiset<pair<int,int>>ms)
{
for(int days=1;days<=n;days++)
{
for(int i=1;i<=x;i++)
{
if(days<=ms.begin()->first+d)
{
ms.erase(ms.begin());
if(ms.empty())
{
return true;
}
}
else
{
return false;
}
}
}
if(ms.empty())
{
return true;
}
else
{
return false;
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("TEST.inp","r",stdin);
cin>>n>>d>>m;
multiset<pair<int,int>>ms;
for(int i=1;i<=m;i++)
{
int x; cin>>x;
ms.insert({x,i});
}
int l=1,r=1000000,ans=r;
while(l<=r)
{
int mid=(l+r)/2;
if(check(mid,ms))
{
ans=mid;
r=mid-1;
}
else
{
l=mid+1;
}
}
cout<<ans<<'\n';
for(int days=1;days<=n;days++)
{
if(!ms.empty())
{
for(int i=1;i<=ans;i++)
{
if(days<=ms.begin()->first+d)
{
cout<<ms.begin()->second<<' ';
ms.erase(ms.begin());
if(ms.empty())
{
break;
}
}
}
}
cout<<0<<'\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |