Submission #14136

# Submission time Handle Problem Language Result Execution time Memory
14136 2015-05-02T08:14:17 Z ggoh Be Two Bees (OJUZ10_b2b) C++
33 / 100
1000 ms 4224 KB
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
long long a,b,i,j,m,X,Y,p=1,q=2,T1[1002],T2[1002];
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<=a;i++)
		{
			for(j=1;j<=m;j++)
			{
				if(T1[j]&&T1[j]!=i)
				{
					if(com(i,T1[j])<com(p,q))p=i,q=T1[j];
				}
				else if(T2[j])
				{
					if(com(i,T2[j])<com(p,q))p=i,q=T2[j];
				}
			}
		}
		printf("%d %d",p,q);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4224 KB Output is correct
2 Correct 0 ms 4224 KB Output is correct
3 Correct 0 ms 4224 KB Output is correct
4 Correct 0 ms 4224 KB Output is correct
5 Correct 0 ms 4224 KB Output is correct
6 Correct 0 ms 4224 KB Output is correct
7 Correct 0 ms 4224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4224 KB Output is correct
2 Correct 15 ms 4224 KB Output is correct
3 Correct 15 ms 4224 KB Output is correct
4 Correct 4 ms 4224 KB Output is correct
5 Correct 14 ms 4224 KB Output is correct
6 Correct 15 ms 4224 KB Output is correct
7 Correct 2 ms 4224 KB Output is correct
8 Correct 15 ms 4224 KB Output is correct
9 Correct 15 ms 4224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 4224 KB Output is correct
2 Correct 677 ms 4224 KB Output is correct
3 Execution timed out 1000 ms 4224 KB Program timed out
4 Execution timed out 1000 ms 4224 KB Program timed out
5 Correct 522 ms 4224 KB Output is correct
6 Execution timed out 1000 ms 4220 KB Program timed out
7 Execution timed out 1000 ms 4224 KB Program timed out
8 Execution timed out 1000 ms 4220 KB Program timed out
9 Correct 837 ms 4224 KB Output is correct
10 Correct 870 ms 4224 KB Output is correct
11 Correct 250 ms 4224 KB Output is correct
12 Correct 997 ms 4224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 4220 KB SIGSEGV Segmentation fault
2 Runtime error 0 ms 4220 KB SIGSEGV Segmentation fault
3 Runtime error 16 ms 4220 KB SIGSEGV Segmentation fault
4 Runtime error 32 ms 4220 KB SIGSEGV Segmentation fault
5 Runtime error 45 ms 4220 KB SIGSEGV Segmentation fault
6 Runtime error 34 ms 4220 KB SIGSEGV Segmentation fault
7 Runtime error 53 ms 4220 KB SIGSEGV Segmentation fault
8 Runtime error 34 ms 4220 KB SIGSEGV Segmentation fault
9 Runtime error 39 ms 4220 KB SIGSEGV Segmentation fault
10 Runtime error 20 ms 4220 KB SIGSEGV Segmentation fault
11 Runtime error 35 ms 4220 KB SIGSEGV Segmentation fault
12 Runtime error 25 ms 4220 KB SIGSEGV Segmentation fault
13 Runtime error 0 ms 4220 KB SIGSEGV Segmentation fault
14 Runtime error 42 ms 4220 KB SIGSEGV Segmentation fault
15 Runtime error 44 ms 4220 KB SIGSEGV Segmentation fault
16 Runtime error 41 ms 4220 KB SIGSEGV Segmentation fault
17 Runtime error 32 ms 4220 KB SIGSEGV Segmentation fault