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>
using namespace std;
int N,H[100100],T[100100],S;
struct p{
p(){
a = i = 0;
}
p(double a_, int i_){
a = a_; i = i_;
}
double a; int i;
bool operator <(const p t) const{
return a > t.a;
}
}P[100100];
bool go(double m)
{
for (int i=0;i<N;i++){
P[i] = p(m/T[i]+H[i],i+1);
}
sort(P,P+N);
return P[0].a + P[1].a > S;
}
int main()
{
scanf ("%d",&N);
for (int i=0;i<N;i++){
scanf ("%d",&H[i]); S += H[i];
}
for (int j=0;j<N;j++) scanf ("%d",&T[j]);
double l = 0, r = 1e9, m;
for (int i=0;i<60;i++){
m = (l + r) / 2;
if (go(m)) r = m;
else l = m;
}
go(l);
int a = P[0].i, b = P[1].i;
if (a > b) swap(a,b);
printf ("%d %d\n",a,b);
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... |