#include <stdio.h>
#include <algorithm>
int h[100000];
int t[100000];
double f[100000];
int arr[100000];
const double EPS=1e-8;
inline bool cmp(const int& a, const int& b)
{
return f[a]>f[b];
}
int main()
{
int r1, r2, n, b, i;
double m=0, s=0, g=500000000000000.0, x;
scanf("%d", &n);
for(i=0;i<n;i++)
scanf("%d", &h[i]);
for(i=0;i<n;i++)
scanf("%d", &t[i]);
for(i=0;i<n;i++)
m+=h[i];
for(b=0;b<40&&s+EPS<g;b++)
{
x=(s+g)/2;
for(i=0;i<n;i++)
{
arr[i]=i;
f[i]=x/t[i]+h[i];
}
std::sort(arr, arr+n,cmp);
if(f[arr[0]]+f[arr[1]]>=m)
{
r1=std::min(arr[0], arr[1]);
r2=std::max(arr[0], arr[1]);
g=x;
}
else
s=x;
}
printf("%d %d", r1+1, r2+1);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
3036 KB |
Output is correct |
2 |
Correct |
0 ms |
3036 KB |
Output is correct |
3 |
Correct |
0 ms |
3036 KB |
Output is correct |
4 |
Correct |
0 ms |
3036 KB |
Output is correct |
5 |
Incorrect |
0 ms |
3036 KB |
Output isn't correct |
6 |
Correct |
0 ms |
3036 KB |
Output is correct |
7 |
Correct |
0 ms |
3036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
3036 KB |
Output is correct |
2 |
Correct |
4 ms |
3036 KB |
Output is correct |
3 |
Correct |
2 ms |
3036 KB |
Output is correct |
4 |
Correct |
4 ms |
3036 KB |
Output is correct |
5 |
Correct |
1 ms |
3036 KB |
Output is correct |
6 |
Incorrect |
0 ms |
3036 KB |
Output isn't correct |
7 |
Correct |
5 ms |
3036 KB |
Output is correct |
8 |
Correct |
4 ms |
3036 KB |
Output is correct |
9 |
Correct |
5 ms |
3036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
293 ms |
3036 KB |
Output is correct |
2 |
Correct |
522 ms |
3036 KB |
Output is correct |
3 |
Correct |
775 ms |
3036 KB |
Output is correct |
4 |
Correct |
225 ms |
3036 KB |
Output is correct |
5 |
Correct |
604 ms |
3036 KB |
Output is correct |
6 |
Correct |
735 ms |
3036 KB |
Output is correct |
7 |
Correct |
788 ms |
3036 KB |
Output is correct |
8 |
Correct |
780 ms |
3036 KB |
Output is correct |
9 |
Correct |
271 ms |
3036 KB |
Output is correct |
10 |
Correct |
424 ms |
3036 KB |
Output is correct |
11 |
Correct |
784 ms |
3036 KB |
Output is correct |
12 |
Correct |
342 ms |
3036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
429 ms |
3036 KB |
Output is correct |
2 |
Correct |
791 ms |
3036 KB |
Output is correct |
3 |
Correct |
530 ms |
3036 KB |
Output is correct |
4 |
Correct |
784 ms |
3036 KB |
Output is correct |
5 |
Correct |
786 ms |
3036 KB |
Output is correct |
6 |
Correct |
516 ms |
3036 KB |
Output is correct |
7 |
Correct |
786 ms |
3036 KB |
Output is correct |
8 |
Correct |
789 ms |
3036 KB |
Output is correct |
9 |
Correct |
788 ms |
3036 KB |
Output is correct |
10 |
Correct |
792 ms |
3036 KB |
Output is correct |
11 |
Correct |
788 ms |
3036 KB |
Output is correct |
12 |
Correct |
794 ms |
3036 KB |
Output is correct |
13 |
Correct |
779 ms |
3036 KB |
Output is correct |
14 |
Correct |
532 ms |
3036 KB |
Output is correct |
15 |
Correct |
562 ms |
3036 KB |
Output is correct |
16 |
Correct |
783 ms |
3036 KB |
Output is correct |
17 |
Correct |
113 ms |
3036 KB |
Output is correct |