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 <stdio.h>
#include <algorithm>
int h[100000];
int t[100000];
double f[100000];
int arr[100000];
const double EPS=1e-7;
inline bool cmp(const int& a, const int& b)
{
return f[a]>f[b];
}
int main()
{
int r1, r2, n, b, i;
double m=0, s=0, g=500000000000000.0, x;
scanf("%d", &n);
for(i=0;i<n;i++)
scanf("%d", &h[i]);
for(i=0;i<n;i++)
scanf("%d", &t[i]);
for(i=0;i<n;i++)
m+=h[i];
for(b=0;b<60&&s+EPS<g;b++)
{
x=(s+g)/2;
for(i=0;i<n;i++)
{
arr[i]=i;
f[i]=x/t[i]+h[i];
}
std::sort(arr, arr+n,cmp);
if(f[arr[0]]+f[arr[1]]>=m)
{
r1=std::min(arr[0], arr[1]);
r2=std::max(arr[0], arr[1]);
g=x;
}
else
s=x;
}
printf("%d %d", r1+1, r2+1);
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... |