Submission #13932

# Submission time Handle Problem Language Result Execution time Memory
13932 2015-04-24T04:05:11 Z model_code Be Two Bees (OJUZ10_b2b) C++
100 / 100
67 ms 2648 KB
#include<stdio.h>

int n, da, db;
long long sum, hi[100100], ti[100100];
double mi=0, mx, md;

double pick(int a, int b){
	double honey=sum-hi[a]-hi[b];
	double til=(1.0/ti[a])+(1.0/ti[b]);
	return honey/til;
}

bool test(double vl){
	double ma=0, mb=0;
	int i, ia, ib;
	for(i=0; i<n; i++){
		double gp=hi[i]+vl/ti[i];
		if(ma<gp)mb=ma, ib=ia, ma=gp, ia=i;
		else if(mb<gp)mb=gp, ib=i;
	}
	if(ma+mb > sum)da=ia, db=ib;
	return (ma+mb) > sum;
}

int main(){
	int i;
	scanf("%d", &n);
	for(i=0; i<n; i++)scanf("%lld", &hi[i]), sum+=hi[i];
	for(i=0; i<n; i++)scanf("%lld", &ti[i]);
	da=0, db=1, mx=pick(0,1);
	while((mx-mi)/mx > 1e-10){
		md=(mi+mx)/2.0;
		if(test(md))mx=pick(da,db);
		else mi=md;
	}
	if(da>db){
		int im=da;
		da=db, db=im;
	}
	printf("%d %d", da+1, db+1);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2648 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2648 KB Output is correct
4 Correct 0 ms 2648 KB Output is correct
5 Correct 0 ms 2648 KB Output is correct
6 Correct 0 ms 2648 KB Output is correct
7 Correct 0 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2648 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2648 KB Output is correct
4 Correct 0 ms 2648 KB Output is correct
5 Correct 0 ms 2648 KB Output is correct
6 Correct 0 ms 2648 KB Output is correct
7 Correct 0 ms 2648 KB Output is correct
8 Correct 0 ms 2648 KB Output is correct
9 Correct 0 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 2648 KB Output is correct
2 Correct 36 ms 2648 KB Output is correct
3 Correct 64 ms 2648 KB Output is correct
4 Correct 21 ms 2648 KB Output is correct
5 Correct 38 ms 2648 KB Output is correct
6 Correct 33 ms 2648 KB Output is correct
7 Correct 30 ms 2648 KB Output is correct
8 Correct 54 ms 2648 KB Output is correct
9 Correct 55 ms 2648 KB Output is correct
10 Correct 58 ms 2648 KB Output is correct
11 Correct 58 ms 2648 KB Output is correct
12 Correct 52 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 2648 KB Output is correct
2 Correct 61 ms 2648 KB Output is correct
3 Correct 19 ms 2648 KB Output is correct
4 Correct 51 ms 2648 KB Output is correct
5 Correct 57 ms 2648 KB Output is correct
6 Correct 42 ms 2648 KB Output is correct
7 Correct 50 ms 2648 KB Output is correct
8 Correct 65 ms 2648 KB Output is correct
9 Correct 59 ms 2648 KB Output is correct
10 Correct 59 ms 2648 KB Output is correct
11 Correct 46 ms 2648 KB Output is correct
12 Correct 65 ms 2648 KB Output is correct
13 Correct 67 ms 2648 KB Output is correct
14 Correct 64 ms 2648 KB Output is correct
15 Correct 33 ms 2648 KB Output is correct
16 Correct 59 ms 2648 KB Output is correct
17 Correct 64 ms 2648 KB Output is correct