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