#include<stdio.h>
#include<algorithm>
using namespace std;
int n,p1,p2;
long long sum,h[100010],t[100010];
double st=0,en,mid;
int pro(double v){
int i;
double s,maxi1=0,maxi2=0;
for(i=1;i<=n;i++){
s=h[i]+v/t[i];
if(maxi1<s) maxi1=s, p1=i;
}
for(i=1;i<=n;i++){
s=h[i]+v/t[i];
if(maxi2<s && p1!=i) maxi2=s, p2=i;
}
if(maxi1+maxi2>=sum) return 1;
return 0;
}
int main()
{
int i,c=0;
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%lld",&h[i]), sum+=h[i];
for(i=1;i<=n;i++) scanf("%lld",&t[i]);
en=double(sum-h[1]-h[2])/(1.0/t[1]+1.0/t[2]);
while(en-st>1e-5){
c++;
if(c==200) break;
mid=(st+en)/2.0;
if(pro(mid)==1) en=mid;
else st=mid;
}
printf("%d %d",min(p1,p2),max(p1,p2));
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 |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 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 |
8 |
Correct |
0 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
142 ms |
2644 KB |
Output is correct |
2 |
Correct |
136 ms |
2644 KB |
Output is correct |
3 |
Correct |
211 ms |
2644 KB |
Output is correct |
4 |
Correct |
52 ms |
2644 KB |
Output is correct |
5 |
Correct |
45 ms |
2644 KB |
Output is correct |
6 |
Correct |
81 ms |
2644 KB |
Output is correct |
7 |
Correct |
131 ms |
2644 KB |
Output is correct |
8 |
Correct |
142 ms |
2644 KB |
Output is correct |
9 |
Correct |
431 ms |
2644 KB |
Output is correct |
10 |
Correct |
121 ms |
2644 KB |
Output is correct |
11 |
Correct |
130 ms |
2644 KB |
Output is correct |
12 |
Correct |
98 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
434 ms |
2644 KB |
Output is correct |
2 |
Correct |
139 ms |
2644 KB |
Output is correct |
3 |
Correct |
440 ms |
2644 KB |
Output is correct |
4 |
Correct |
429 ms |
2644 KB |
Output is correct |
5 |
Correct |
436 ms |
2644 KB |
Output is correct |
6 |
Correct |
434 ms |
2644 KB |
Output is correct |
7 |
Correct |
156 ms |
2644 KB |
Output is correct |
8 |
Correct |
156 ms |
2644 KB |
Output is correct |
9 |
Correct |
158 ms |
2644 KB |
Output is correct |
10 |
Correct |
151 ms |
2644 KB |
Output is correct |
11 |
Correct |
98 ms |
2644 KB |
Output is correct |
12 |
Correct |
431 ms |
2644 KB |
Output is correct |
13 |
Correct |
152 ms |
2644 KB |
Output is correct |
14 |
Correct |
98 ms |
2644 KB |
Output is correct |
15 |
Correct |
429 ms |
2644 KB |
Output is correct |
16 |
Correct |
88 ms |
2644 KB |
Output is correct |
17 |
Correct |
440 ms |
2644 KB |
Output is correct |