#include<stdio.h>
int n, da, db;
long long sum, hi[100100], ti[100100];
double mi=0, mx, md;
double pick(int a, int b){
double honey=sum-hi[a]-hi[b];
double til=(1.0/ti[a])+(1.0/ti[b]);
return honey/til;
}
bool test(double vl){
double ma=0, mb=0;
int i, ia, ib;
for(i=0; i<n; i++){
double gp=hi[i]+vl/ti[i];
if(ma<gp)mb=ma, ib=ia, ma=gp, ia=i;
else if(mb<gp)mb=gp, ib=i;
}
if(ma+mb > sum)da=ia, db=ib;
return (ma+mb) > sum;
}
int main(){
int i;
scanf("%d", &n);
for(i=0; i<n; i++)scanf("%lld", &hi[i]), sum+=hi[i];
for(i=0; i<n; i++)scanf("%lld", &ti[i]);
da=0, db=1, mx=pick(0,1);
while((mx-mi)/mx > 1e-10){
md=(mi+mx)/2.0;
if(test(md))mx=pick(da,db);
else mi=md;
}
if(da>db){
int im=da;
da=db, db=im;
}
printf("%d %d", 1, 2);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
2648 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
58 ms |
2648 KB |
Output isn't correct |
2 |
Incorrect |
21 ms |
2648 KB |
Output isn't correct |
3 |
Incorrect |
37 ms |
2648 KB |
Output isn't correct |
4 |
Incorrect |
58 ms |
2648 KB |
Output isn't correct |
5 |
Incorrect |
60 ms |
2648 KB |
Output isn't correct |
6 |
Incorrect |
58 ms |
2648 KB |
Output isn't correct |
7 |
Incorrect |
40 ms |
2648 KB |
Output isn't correct |
8 |
Incorrect |
33 ms |
2648 KB |
Output isn't correct |
9 |
Incorrect |
36 ms |
2648 KB |
Output isn't correct |
10 |
Incorrect |
63 ms |
2648 KB |
Output isn't correct |
11 |
Incorrect |
57 ms |
2648 KB |
Output isn't correct |
12 |
Incorrect |
58 ms |
2648 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
2648 KB |
Output isn't correct |
2 |
Incorrect |
37 ms |
2648 KB |
Output isn't correct |
3 |
Incorrect |
60 ms |
2648 KB |
Output isn't correct |
4 |
Correct |
17 ms |
2648 KB |
Output is correct |
5 |
Incorrect |
64 ms |
2648 KB |
Output isn't correct |
6 |
Incorrect |
53 ms |
2648 KB |
Output isn't correct |
7 |
Incorrect |
62 ms |
2648 KB |
Output isn't correct |
8 |
Incorrect |
59 ms |
2648 KB |
Output isn't correct |
9 |
Incorrect |
71 ms |
2648 KB |
Output isn't correct |
10 |
Incorrect |
63 ms |
2648 KB |
Output isn't correct |
11 |
Incorrect |
38 ms |
2648 KB |
Output isn't correct |
12 |
Incorrect |
62 ms |
2648 KB |
Output isn't correct |
13 |
Incorrect |
60 ms |
2648 KB |
Output isn't correct |
14 |
Incorrect |
64 ms |
2648 KB |
Output isn't correct |
15 |
Incorrect |
64 ms |
2648 KB |
Output isn't correct |
16 |
Incorrect |
43 ms |
2648 KB |
Output isn't correct |
17 |
Incorrect |
65 ms |
2648 KB |
Output isn't correct |