Submission #14343

#TimeUsernameProblemLanguageResultExecution timeMemory
14343cometBe Two Bees (OJUZ10_b2b)C++98
0 / 100
826 ms4324 KiB
#include<bits/stdc++.h> using namespace std; int n; double sum,H[111111],T[111111],a[111111]; bool check(double k){ for(int i=0;i<n;i++)a[i]=H[i]+k*T[i]; sort(a,a+n); double ret=0; for(int i=0;i<n-2;i++)ret+=a[i]; //printf("%f : %f\n",ret,k*sum); return ret>=k*sum; } void output(double k){ double Max=0; 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(Max<a[i]){ Max=a[i]; v=i; } } Max=0; for(int i=0;i<n;i++){ if(Max<a[i]&&i!=v){ Max=a[i]; v2=i; } } printf("%d %d\n",v+1,v2+1); } int main(){ scanf("%d",&n); int x,y,z; for(int i=0;i<n;i++)scanf("%lf",&H[i]); for(int i=0;i<n;i++){ scanf("%lf",&T[i]); T[i]=(double)1/T[i]; sum+=T[i]; } double lo=0,hi=1e18,mid; for(int i=0;i<80;i++){ mid=(lo+hi)/2; if(check(mid)){ lo=mid; } else{ hi=mid; } //printf("%f %f\n",lo,hi); } output(hi); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...