# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062293 | Kiet07 | Job Scheduling (CEOI12_jobs) | C++14 | 180 ms | 17136 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;
pair<int,int>a[1000005];
bool check(int x)
{
int j=1;
for(int days=1;days<=n;days++)
{
for(int i=1;i<=x;i++)
{
if(days>=a[j].first)
{
if(days<=a[j].first+d)
{
j++;
if(j==m+1)return true;
}
else
{
return false;
}
}
else
{
break;
}
}
}
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;
for(int i=1;i<=m;i++)
{
cin>>a[i].first;
a[i].second=i;
}
sort(a+1,a+m+1);
int l=1,r=1000000,ans=r;
while(l<=r)
{
int mid=(l+r)/2;
if(check(mid))
{
ans=mid;
r=mid-1;
}
else
{
l=mid+1;
}
}
cout<<ans<<'\n';
int j=1;
for(int days=1;days<=n;days++)
{
if(j<=m)
{
for(int i=1;i<=ans;i++)
{
if(days>=a[j].first&&days<=a[j].first+d)
{
cout<<a[j].second<<' ';
j++;
if(j==m+1)
{
break;
}
}
}
}
cout<<0<<'\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |