답안 #79318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
79318 2018-10-12T08:15:44 Z aminra Sure Bet (CEOI17_sure) C++14
20 / 100
2 ms 704 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e5 + 7;
const int infint = (int)1e9;
int n;
ld a[MAXN], b[MAXN];
ld g(int mid, int ted)
{
	ld c1 = 0;
	if(mid)
		c1 = a[mid - 1];
	mid = ted - mid;
	ld c2 = 0;
	if(mid)
		c2 = b[mid - 1];
	return min(c1, c2);
}
ld f(int ted)
{
	//jelo tarin i ro mikhaim ke g(i) > g(i - 1)
	int L = 0, R = ted + 1;
	while(R - L > 1)
	{
		int mid = (R + L) >> 1;
		if(g(mid, ted) > g(mid - 1, ted))
			L = mid;
		else
			R = mid;
	}
	return g(L, ted);
}
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);
	sort(b, b + n);
	reverse(a, a + n);
	reverse(b, b + n);
	for (int i = 1; i < n; i++)
		a[i] += a[i - 1], b[i] += b[i - 1];
	ld ans = 0;
	for (int i = 1; i <= 2 * n; i++)
		ans = max(ans, f(i) - i);
	cout << fixed << setprecision(4) << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 2 ms 660 KB Output is correct
9 Incorrect 2 ms 704 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 2 ms 660 KB Output is correct
9 Incorrect 2 ms 704 KB Output isn't correct
10 Halted 0 ms 0 KB -