Submission #171916

# Submission time Handle Problem Language Result Execution time Memory
171916 2019-12-30T15:40:28 Z dvdg6566 Sure Bet (CEOI17_sure) C++14
20 / 100
2 ms 396 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ld> vi;
typedef pair<ld,ld> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 101010

vector<ld> A,B;
ld a,b;
int N;

bool work(ld v){
	ld x = v;
	ld y = v;
	int a = 0;
	int b = 0;
	while(x > 0 || y > 0){
		++x;++y;
		if (x > 0){
			if (a==SZ(A))return 0;
			x -= A[a];
			++a;
		}else if (y > 0){
			if (b==SZ(B))return 0;
			y -= B[b];
			++b;
		}
	}
	return 1;
}

int main(){
	cin>>N;
	for (int i=1;i<=N;++i){
		cin>>a>>b;
		if (a>1)A.pb(a);
		if (b>1)B.pb(b);
	}
	sort(ALL(A));reverse(ALL(A));
	sort(ALL(B));reverse(ALL(B));

	ld ub=100000000;
	ld lb=0;
	while (ub>lb+0.000001){
		ld mid=(lb+ub)/2;
		if (work(mid))lb = mid;
		else ub = mid;	
	}
	lb *= 10000;
	lb = roundf(lb);
	printf("%.4lf",(double)(lb/10000));
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 396 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Incorrect 2 ms 376 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 396 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Incorrect 2 ms 376 KB Output isn't correct
12 Halted 0 ms 0 KB -