#include<stdio.h>
#include<algorithm>
using namespace std;
int n,p1,p2;
long long sum,h[100010],t[100010];
double st=0,en=1e+10,mid;
int pro(double v){
int i,s;
double 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;
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%d",&h[i]), sum+=h[i];
for(i=1;i<=n;i++) scanf("%d",&t[i]);
while(en-st>1e-3){
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2644 KB |
Output isn't 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2644 KB |
Output is correct |
2 |
Correct |
0 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 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 |
Incorrect |
0 ms |
2644 KB |
Output isn't correct |
9 |
Correct |
0 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
2644 KB |
Output is correct |
2 |
Incorrect |
60 ms |
2644 KB |
Output isn't correct |
3 |
Correct |
59 ms |
2644 KB |
Output is correct |
4 |
Incorrect |
68 ms |
2644 KB |
Output isn't correct |
5 |
Correct |
106 ms |
2644 KB |
Output is correct |
6 |
Correct |
111 ms |
2644 KB |
Output is correct |
7 |
Correct |
116 ms |
2644 KB |
Output is correct |
8 |
Correct |
80 ms |
2644 KB |
Output is correct |
9 |
Correct |
40 ms |
2644 KB |
Output is correct |
10 |
Correct |
111 ms |
2644 KB |
Output is correct |
11 |
Incorrect |
113 ms |
2644 KB |
Output isn't correct |
12 |
Incorrect |
121 ms |
2644 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
2644 KB |
Output is correct |
2 |
Correct |
117 ms |
2644 KB |
Output is correct |
3 |
Correct |
77 ms |
2644 KB |
Output is correct |
4 |
Correct |
122 ms |
2644 KB |
Output is correct |
5 |
Incorrect |
118 ms |
2644 KB |
Output isn't correct |
6 |
Incorrect |
124 ms |
2644 KB |
Output isn't correct |
7 |
Correct |
109 ms |
2644 KB |
Output is correct |
8 |
Correct |
123 ms |
2644 KB |
Output is correct |
9 |
Incorrect |
118 ms |
2644 KB |
Output isn't correct |
10 |
Correct |
121 ms |
2644 KB |
Output is correct |
11 |
Correct |
72 ms |
2644 KB |
Output is correct |
12 |
Correct |
78 ms |
2644 KB |
Output is correct |
13 |
Correct |
116 ms |
2644 KB |
Output is correct |
14 |
Correct |
113 ms |
2644 KB |
Output is correct |
15 |
Correct |
119 ms |
2644 KB |
Output is correct |
16 |
Incorrect |
118 ms |
2644 KB |
Output isn't correct |
17 |
Incorrect |
113 ms |
2644 KB |
Output isn't correct |