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 <cstdio>
int n;
int eat[100010];
int make[100010];
int ch1, ch2;
typedef long long ll;
ll sumeat;
bool chk(double x){
int mi=-1, smi=-1;
double mv=-1e280, smv=-1e280;
for(int i=0;i<n;++i){
double cv=x*make[i]+eat[i];
if(mv < cv){
smv=mv; smi=mi;
mv=cv; mi=i;
} else if(smv<cv){
smv=cv; smi=i;
}
}
if(mv+smv >= sumeat){
ch1=mi; ch2=smi;
return true;
}
return false;
}
int main()
{
scanf("%d",&n);
int i;
for(i=0;i<n;++i) scanf("%d",eat+i), sumeat += eat[i];
for(i=0;i<n;++i) scanf("%d",make+i);
double l=0, r=1e20, mid;
for(i=0;i<100;++i){
(chk(mid=(l+r)/2)?r:l)=mid;
}
if(ch1>ch2) ch2+=ch1, ch1=ch2-ch1, ch2=ch2-ch1;
printf("%d %d\n",ch1,ch2);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |