Submission #13942

# Submission time Handle Problem Language Result Execution time Memory
13942 2015-04-24T06:32:47 Z imsifile Be Two Bees (OJUZ10_b2b) C++
0 / 100
62 ms 7344 KB
#include<stdio.h>
#include<algorithm>
using namespace std;

struct a1 {
	long long h, t;
	int ix;
	bool operator< (const a1& c) const {
		if(h!=c.h)return h>c.h;
		return t<c.t;
	}
}ba1[100100];

struct a2 {
	long long h, t;
	int ix;
	bool operator< (const a2& c) const {
		if(t!=c.t)return t<c.t;
		return h>c.h;
	}
}ba2[100100];

int n, da, db;
long long sum, hi[100100], ti[100100];
double dap;

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;
}

int main(){
	int i, j;
	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]);
	for(i=0; i<n; i++){
		ba1[i].ix=ba2[i].ix=i;
		ba1[i].h=ba2[i].h=hi[i];
		ba1[i].t=ba2[i].t=ti[i];
	}
	sort(ba1,ba1+n);
	sort(ba2,ba2+n);
	da=0, db=1, dap=pick(0,1);
	for(i=0; i<2; i++){
		for(j=0; j<2; j++){
			if(ba1[i].ix != ba2[j].ix){
				double gap=pick(ba1[i].ix, ba2[j].ix);
				if(dap>gap)dap=gap, da=ba1[i].ix, db=ba2[j].ix;
			}
			if(ba1[i].ix != ba1[j].ix){
				double gap=pick(ba1[i].ix, ba1[j].ix);
				if(dap>gap)dap=gap, da=ba1[i].ix, db=ba1[j].ix;
			}
			if(ba2[i].ix != ba2[j].ix){
				double gap=pick(ba2[i].ix, ba2[j].ix);
				if(dap>gap)dap=gap, da=ba2[i].ix, db=ba2[j].ix;
			}
		}
	}
	if(da>db)swap(da,db);
	printf("%d %d", da+1, db+1);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 7344 KB Output is correct
2 Correct 0 ms 7344 KB Output is correct
3 Correct 0 ms 7344 KB Output is correct
4 Correct 0 ms 7344 KB Output is correct
5 Correct 0 ms 7344 KB Output is correct
6 Correct 0 ms 7344 KB Output is correct
7 Incorrect 0 ms 7344 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 7344 KB Output is correct
2 Correct 0 ms 7344 KB Output is correct
3 Correct 0 ms 7344 KB Output is correct
4 Incorrect 0 ms 7344 KB Output isn't correct
5 Correct 0 ms 7344 KB Output is correct
6 Correct 0 ms 7344 KB Output is correct
7 Correct 0 ms 7344 KB Output is correct
8 Correct 0 ms 7344 KB Output is correct
9 Correct 1 ms 7344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 7344 KB Output is correct
2 Correct 58 ms 7344 KB Output is correct
3 Correct 49 ms 7344 KB Output is correct
4 Correct 38 ms 7344 KB Output is correct
5 Correct 31 ms 7344 KB Output is correct
6 Correct 28 ms 7344 KB Output is correct
7 Correct 49 ms 7344 KB Output is correct
8 Correct 25 ms 7344 KB Output is correct
9 Incorrect 39 ms 7344 KB Output isn't correct
10 Correct 49 ms 7344 KB Output is correct
11 Correct 45 ms 7344 KB Output is correct
12 Correct 13 ms 7344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 7344 KB Output is correct
2 Correct 34 ms 7344 KB Output is correct
3 Correct 50 ms 7344 KB Output is correct
4 Correct 48 ms 7344 KB Output is correct
5 Correct 47 ms 7344 KB Output is correct
6 Correct 51 ms 7344 KB Output is correct
7 Correct 38 ms 7344 KB Output is correct
8 Correct 51 ms 7344 KB Output is correct
9 Correct 47 ms 7344 KB Output is correct
10 Correct 48 ms 7344 KB Output is correct
11 Incorrect 53 ms 7344 KB Output isn't correct
12 Correct 36 ms 7344 KB Output is correct
13 Correct 55 ms 7344 KB Output is correct
14 Incorrect 41 ms 7344 KB Output isn't correct
15 Correct 12 ms 7344 KB Output is correct
16 Correct 62 ms 7344 KB Output is correct
17 Correct 45 ms 7344 KB Output is correct