Submission #13941

# Submission time Handle Problem Language Result Execution time Memory
13941 2015-04-24T06:32:04 Z imsifile Be Two Bees (OJUZ10_b2b) C++
33 / 100
65 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<3; i++){
		for(j=0; j<3; 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 Correct 0 ms 7344 KB Output is 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 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 Correct 0 ms 7344 KB Output is correct
8 Correct 0 ms 7344 KB Output is correct
9 Correct 0 ms 7344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 7344 KB Output is correct
2 Correct 52 ms 7344 KB Output is correct
3 Correct 56 ms 7344 KB Output is correct
4 Correct 38 ms 7344 KB Output is correct
5 Correct 27 ms 7344 KB Output is correct
6 Correct 32 ms 7344 KB Output is correct
7 Correct 60 ms 7344 KB Output is correct
8 Correct 29 ms 7344 KB Output is correct
9 Incorrect 30 ms 7344 KB Output isn't correct
10 Correct 51 ms 7344 KB Output is correct
11 Correct 51 ms 7344 KB Output is correct
12 Correct 18 ms 7344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 7344 KB Output is correct
2 Correct 37 ms 7344 KB Output is correct
3 Correct 52 ms 7344 KB Output is correct
4 Correct 53 ms 7344 KB Output is correct
5 Correct 54 ms 7344 KB Output is correct
6 Correct 57 ms 7344 KB Output is correct
7 Correct 37 ms 7344 KB Output is correct
8 Correct 57 ms 7344 KB Output is correct
9 Correct 63 ms 7344 KB Output is correct
10 Correct 50 ms 7344 KB Output is correct
11 Incorrect 42 ms 7344 KB Output isn't correct
12 Correct 27 ms 7344 KB Output is correct
13 Correct 52 ms 7344 KB Output is correct
14 Incorrect 43 ms 7344 KB Output isn't correct
15 Correct 13 ms 7344 KB Output is correct
16 Correct 55 ms 7344 KB Output is correct
17 Correct 50 ms 7344 KB Output is correct