#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-10){
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 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
2 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
3 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
4 |
Correct |
0 ms |
2644 KB |
Output is correct |
5 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
6 |
Correct |
0 ms |
2644 KB |
Output is correct |
7 |
Incorrect |
0 ms |
2644 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
2 |
Incorrect |
0 ms |
2644 KB |
Output isn't correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
5 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
6 |
Correct |
1 ms |
2644 KB |
Output is correct |
7 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
8 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
9 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
136 ms |
2644 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
3 |
Incorrect |
74 ms |
2644 KB |
Output isn't correct |
4 |
Correct |
138 ms |
2644 KB |
Output is correct |
5 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
6 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
7 |
Correct |
61 ms |
2644 KB |
Output is correct |
8 |
Incorrect |
134 ms |
2644 KB |
Output isn't correct |
9 |
Correct |
139 ms |
2644 KB |
Output is correct |
10 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
11 |
Correct |
127 ms |
2644 KB |
Output is correct |
12 |
Incorrect |
130 ms |
2644 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
2 |
Correct |
47 ms |
2644 KB |
Output is correct |
3 |
Correct |
141 ms |
2644 KB |
Output is correct |
4 |
Correct |
135 ms |
2644 KB |
Output is correct |
5 |
Incorrect |
141 ms |
2644 KB |
Output isn't correct |
6 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
7 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
8 |
Execution timed out |
1000 ms |
2640 KB |
Program timed out |
9 |
Correct |
142 ms |
2644 KB |
Output is correct |
10 |
Incorrect |
137 ms |
2644 KB |
Output isn't correct |
11 |
Correct |
140 ms |
2644 KB |
Output is correct |
12 |
Incorrect |
142 ms |
2644 KB |
Output isn't correct |
13 |
Correct |
125 ms |
2644 KB |
Output is correct |
14 |
Correct |
98 ms |
2644 KB |
Output is correct |
15 |
Incorrect |
135 ms |
2644 KB |
Output isn't correct |
16 |
Incorrect |
132 ms |
2644 KB |
Output isn't correct |
17 |
Correct |
136 ms |
2644 KB |
Output is correct |