# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224423 | MKopchev | Job Scheduling (CEOI12_jobs) | C++14 | 357 ms | 17144 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;
const int MX=1e6+42;
int n,d,m;
pair<int,int> inp[MX];
bool can(int sz)
{
int pos=1;
for(int day=1;day<=n&&pos<=m;day++)
{
if(inp[pos].first+d<day)return 0;
int pos_help=pos;
while(pos_help<=m&&pos_help-pos<sz&&inp[pos_help].first<=day)
{
pos_help++;
}
pos=pos_help;
}
return pos>m;
}
int main()
{
scanf("%i%i%i",&n,&d,&m);
for(int i=1;i<=m;i++)
{
scanf("%i",&inp[i].first);
inp[i].second=i;
}
sort(inp+1,inp+m+1);
int ok=m,not_ok=0;
while(ok-not_ok>1)
{
int av=(ok+not_ok)/2;
if(can(av))ok=av;
else not_ok=av;
}
printf("%i\n",ok);
int pos=1;
for(int day=1;day<=n;day++)
{
int pos_help=pos;
while(pos_help<=m&&pos_help-pos<ok&&inp[pos_help].first<=day)
{
printf("%i ",inp[pos_help].second);
pos_help++;
}
pos=pos_help;
printf("0\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |