# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
755684 | Petrix | Job Scheduling (CEOI12_jobs) | C++17 | 5 ms | 724 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 <algorithm>
using namespace std;
int v[10000];
int n,m;
bool verf(int mij){
int z=m-1,i=1;
z=0;i=1;
while(z<m-1 && i<=n){
z=min(z+mij,m-1);
if(i>v[z])
break;
i++;
}
if(z<m-1 && i<=n)
return 0;
else
return 1;
}
int main()
{
int st,dr,mij,d,rasp,i,vf;
cin>>n>>d>>m;
for(i=0;i<m;i++){
cin>>v[i];
v[i]+=d;
}
sort(v,v+m);
st=1;dr=1000000;rasp=mij=0;
while(st<=dr){
mij=(st+dr)/2;
vf=verf(mij);
if(vf==1){
rasp=mij;
dr=mij-1;
}else{
st=mij+1;
}
}
cout<<rasp;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |