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;
typedef long long ll;
int n;
ll sum;
int H[111111],T[111111];
double a[111111];
bool check(double k){
for(int i=0;i<n;i++)a[i]=H[i]+k/T[i];
double ret=0;
double* t=max_element(a,a+n);
ret+=*t;
*t=-1e18;
t=max_element(a,a+n);
ret+=*t;
return ret>sum;
}
void output(double k){
for(int i=0;i<n;i++)a[i]=H[i]+k/T[i];
int v,v2;
double* t=max_element(a,a+n);
v=t-a+1;
*t=-1e18;
t=max_element(a,a+n);
v2=t-a+1;
printf("%d %d",min(v,v2),max(v,v2));
}
int main(){
scanf("%d",&n);
int x,y,z;
for(int i=0;i<n;i++){
scanf("%d",&H[i]);
sum+=H[i];
}
for(int i=0;i<n;i++){
scanf("%d",&T[i]);
}
double lo=0,hi=1e15,mid;
for(int i=0;i<100;i++){
mid=(lo+hi)/2;
if(check(mid)){
hi=mid;
}
else{
lo=mid;
}
//printf("%f %f\n",hi,lo);
}
output(hi);
}
# | 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... |