Submission #120079

# Submission time Handle Problem Language Result Execution time Memory
120079 2019-06-23T08:37:38 Z MB81 Sure Bet (CEOI17_sure) C++11
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int> pii32;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e18;

int64 s1[maxn], s2[maxn];
int64 a[maxn], b[maxn];
int n;

int g1 (int64 x) {
	if (s1[n - 1] < x)
		return n;
	int l = -1, r = n - 1, mid;
	while (r - l > 1) {
		mid = (l + r) >> 1;
		if (s1[mid] >= x)
			r = mid;
		else
			l = mid;
	}
	return r;
}

int g2 (int64 x) {
	if (s2[n - 1] < x)
		return n;
	int l = -1, r = n - 1, mid;
	while (r - l > 1) {
		mid = (l + r) >> 1;
		if (s2[mid] >= x)
			r = mid;
		else
			l = mid;
	}
	return r;
}

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		double x1, x2;
		cin >> x1 >> x2;
		a[i] = x1 * 10000;
		b[i] = x2 * 10000;
	}
	sort(a, a + n); reverse(a, a + n);
	sort(b, b + n); reverse(b, b + n);
	s1[0] = a[0];
	s2[0] = b[0];
	for (int i = 1; i < n; i++) {
		s1[i] = s1[i - 1] + a[i];
		s2[i] = s2[i - 1] + b[i];
	}
	int64 ans = 0;
	for (int i = 1; i < 2 * n; i++) {
		int64 l = 0, r = IN, mid;
		while (r - l > 1) {
			mid = (l + r) / 2;
			int p1 = g1(mid), p2 = g2(mid);
			if (p1 == n || p2 == n || p1 + 1 + p2 + 1 > i)
				r = mid;
			else
				l = mid;
		}
		ans = max(ans, l - i * 10000);
	}
	double dans = 1.0 * ans / 10000;
	cout << fixed << setprecision(4) << dans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -