Submission #120078

# Submission time Handle Problem Language Result Execution time Memory
120078 2019-06-23T08:27:49 Z MB81 Sure Bet (CEOI17_sure) C++14
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 float eps = 1e-5;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

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

int g1 (float x) {
	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 (float x) {
	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++)
		cin >> a[i] >> b[i];
	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];
	}
	float ans = 0;
	for (int i = 1; i < n; i++) {
		float l = 0, r = IN, mid;
		while (r - l > eps) {
			mid = (l + r) / 2;
			int p1 = g1(mid), p2 = g2(mid);
			if (p1 + 1 + p2 + 1 > i)
				r = mid;
			else
				l = mid;
		}
		ans = max(ans, l - i);
	}
	cout << fixed << setprecision(4) << ans << "\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 -