답안 #120090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120090 2019-06-23T08:57:01 Z MB81 Sure Bet (CEOI17_sure) C++11
60 / 100
2000 ms 4832 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 = 1e9;

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

int g1 (double 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 (double 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++)
		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];
	}
	double ans = 0;
	for (int i = 1; i <= 2 * n; i++) {
		double l = 0, r = IN, mid;
		for (int j = 0; j < 100; j++) {
			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);
	}
	cout << fixed << setprecision(4) << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 13 ms 384 KB Output is correct
13 Correct 14 ms 384 KB Output is correct
14 Correct 14 ms 384 KB Output is correct
15 Correct 13 ms 384 KB Output is correct
16 Correct 14 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 13 ms 384 KB Output is correct
13 Correct 14 ms 384 KB Output is correct
14 Correct 14 ms 384 KB Output is correct
15 Correct 13 ms 384 KB Output is correct
16 Correct 14 ms 384 KB Output is correct
17 Execution timed out 2062 ms 4832 KB Time limit exceeded
18 Halted 0 ms 0 KB -