#include <stdio.h>
int n,ai,aj;
long long h[100010],t[100010],H;
int f(double m){
int i,mi,mj;
double s,m1=0,m2=0;
for(i=1;i<=n;++i){
s=h[i]+m/t[i];
if(m1<s)m2=m1,mj=mi,m1=s,mi=i;
else if(m2<s)m2=s,mj=i;
}
if(m1+m2>=H)ai=mi,aj=mj;
return m1+m2>=H;
}
int main(){
int i;
scanf("%d",&n);
for(i=1;i<=n;++i)scanf("%lld",h+i),H+=h[i];
for(i=1;i<=n;++i)scanf("%lld",t+i);
double l=0,r=1e10,m;
while((r-l)/r>1e-8){
m=(l+r)/2;
if(f(m))r=(H-h[ai]-h[aj])/(1.0/t[ai]+1.0/t[aj]);
else l=m;
}
if(ai>aj)ai^=aj^=ai^=aj;
printf("%d %d",ai,aj);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2644 KB |
Output is correct |
2 |
Correct |
0 ms |
2644 KB |
Output is correct |
3 |
Correct |
0 ms |
2644 KB |
Output is correct |
4 |
Correct |
0 ms |
2644 KB |
Output is correct |
5 |
Correct |
0 ms |
2644 KB |
Output is correct |
6 |
Correct |
0 ms |
2644 KB |
Output is correct |
7 |
Correct |
0 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
0 ms |
2644 KB |
Output is correct |
3 |
Correct |
0 ms |
2644 KB |
Output is correct |
4 |
Correct |
0 ms |
2644 KB |
Output is correct |
5 |
Incorrect |
0 ms |
2644 KB |
Output isn't correct |
6 |
Correct |
0 ms |
2644 KB |
Output is correct |
7 |
Incorrect |
0 ms |
2644 KB |
Output isn't correct |
8 |
Correct |
0 ms |
2644 KB |
Output is correct |
9 |
Correct |
0 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
2644 KB |
Output is correct |
2 |
Incorrect |
47 ms |
2644 KB |
Output isn't correct |
3 |
Correct |
55 ms |
2644 KB |
Output is correct |
4 |
Correct |
59 ms |
2644 KB |
Output is correct |
5 |
Correct |
37 ms |
2644 KB |
Output is correct |
6 |
Correct |
20 ms |
2644 KB |
Output is correct |
7 |
Incorrect |
50 ms |
2644 KB |
Output isn't correct |
8 |
Correct |
59 ms |
2644 KB |
Output is correct |
9 |
Incorrect |
50 ms |
2644 KB |
Output isn't correct |
10 |
Correct |
39 ms |
2644 KB |
Output is correct |
11 |
Incorrect |
28 ms |
2644 KB |
Output isn't correct |
12 |
Incorrect |
53 ms |
2644 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
56 ms |
2644 KB |
Output isn't correct |
2 |
Correct |
52 ms |
2644 KB |
Output is correct |
3 |
Correct |
61 ms |
2644 KB |
Output is correct |
4 |
Incorrect |
19 ms |
2644 KB |
Output isn't correct |
5 |
Correct |
60 ms |
2644 KB |
Output is correct |
6 |
Incorrect |
53 ms |
2644 KB |
Output isn't correct |
7 |
Incorrect |
61 ms |
2644 KB |
Output isn't correct |
8 |
Incorrect |
56 ms |
2644 KB |
Output isn't correct |
9 |
Incorrect |
42 ms |
2644 KB |
Output isn't correct |
10 |
Correct |
48 ms |
2644 KB |
Output is correct |
11 |
Incorrect |
56 ms |
2644 KB |
Output isn't correct |
12 |
Correct |
41 ms |
2644 KB |
Output is correct |
13 |
Correct |
57 ms |
2644 KB |
Output is correct |
14 |
Incorrect |
61 ms |
2644 KB |
Output isn't correct |
15 |
Incorrect |
57 ms |
2644 KB |
Output isn't correct |
16 |
Correct |
30 ms |
2644 KB |
Output is correct |
17 |
Incorrect |
55 ms |
2644 KB |
Output isn't correct |