#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
int a,b,i,j,k,m,X,Y,p=1,q=2,T1[100002],T2[100002];
long double H,x[100001],y[100001];
long double com(int ii,int jj)
{
return (H-x[ii]-x[jj])/(y[ii]+y[jj])*y[ii]*y[jj];
}
main()
{
scanf("%d",&a);
for(i=1;i<=a;i++)
{
scanf("%Lf",&x[i]);
H+=x[i];
}
for(j=1;j<=a;j++)
{
scanf("%Lf",&y[j]);
if(m<y[j])m=y[j];
}
if(a<=1000)
{
for(i=1;i<=a;i++)
{
for(j=i+1;j<=a;j++)
{
if(com(i,j)<com(p,q))p=i,q=j;
}
}
printf("%d %d",p,q);
}
else
{
for(i=1;i<=a;i++)
{
if(T1[(int)y[i]]==0)
{
T1[(int)y[i]]=i;
}
else
{
if(x[i]>=x[T1[(int)y[i]]])
{
T2[(int)y[i]]=T1[(int)y[i]];
T1[(int)y[i]]=i;
}
else if(T2[(int)y[i]]==0)T2[(int)y[i]]=i;
else if(x[i]>=x[T2[(int)y[i]]])
{
T2[(int)y[i]]=i;
}
}
}
for(i=1;i<=m;i++)
{
if(T1[i]!=0&&T2[i]!=0&&com(T1[i],T2[i])<com(p,q))p=T1[i],q=T2[i];
for(j=i+1;j<=m;j++)
{
if(T1[i]!=0&&T1[j]!=0&&com(T1[i],T1[j])<com(p,q))p=T1[i],q=T1[j];
}
}
if(p>q)printf("%d %d",q,p);
else printf("%d %d",p,q);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4988 KB |
Output is correct |
2 |
Correct |
0 ms |
4988 KB |
Output is correct |
3 |
Correct |
0 ms |
4988 KB |
Output is correct |
4 |
Correct |
0 ms |
4988 KB |
Output is correct |
5 |
Correct |
0 ms |
4988 KB |
Output is correct |
6 |
Correct |
0 ms |
4988 KB |
Output is correct |
7 |
Correct |
0 ms |
4988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
4988 KB |
Output is correct |
2 |
Correct |
15 ms |
4988 KB |
Output is correct |
3 |
Correct |
0 ms |
4988 KB |
Output is correct |
4 |
Correct |
15 ms |
4988 KB |
Output is correct |
5 |
Correct |
14 ms |
4988 KB |
Output is correct |
6 |
Correct |
15 ms |
4988 KB |
Output is correct |
7 |
Correct |
4 ms |
4988 KB |
Output is correct |
8 |
Correct |
0 ms |
4988 KB |
Output is correct |
9 |
Correct |
15 ms |
4988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
4988 KB |
Output is correct |
2 |
Correct |
32 ms |
4988 KB |
Output is correct |
3 |
Correct |
38 ms |
4988 KB |
Output is correct |
4 |
Correct |
33 ms |
4988 KB |
Output is correct |
5 |
Correct |
30 ms |
4988 KB |
Output is correct |
6 |
Correct |
33 ms |
4988 KB |
Output is correct |
7 |
Correct |
34 ms |
4988 KB |
Output is correct |
8 |
Correct |
24 ms |
4988 KB |
Output is correct |
9 |
Correct |
38 ms |
4988 KB |
Output is correct |
10 |
Correct |
31 ms |
4988 KB |
Output is correct |
11 |
Correct |
13 ms |
4988 KB |
Output is correct |
12 |
Correct |
32 ms |
4988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
4988 KB |
Program timed out |
2 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
3 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
4 |
Execution timed out |
1000 ms |
4988 KB |
Program timed out |
5 |
Execution timed out |
1000 ms |
4988 KB |
Program timed out |
6 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
7 |
Correct |
156 ms |
4988 KB |
Output is correct |
8 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
9 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
10 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
11 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
12 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
13 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
14 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
15 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
16 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |
17 |
Execution timed out |
1000 ms |
4984 KB |
Program timed out |