답안 #879271

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879271 2023-11-27T05:03:42 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
63 ms 8516 KB
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

using ld = double;

const int N = 1e6 + 123;

ld a[N], b[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1 ; i <= n ; ++ i) cin >> a[i] >> b[i];
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);
	reverse(a + 1, a + 1 + n);
	reverse(b + 1, b + 1 + n);
	for (int i = 1 ; i <= n ; ++ i) a[i] += a[i - 1], b[i] += b[i - 1];
	int l = 1, r = 1;
	ld ans = max(0.0, min(a[1], b[1]) - 2);
	while (l < n || r < n) {
		if (l == n || (r < n && min(a[l], b[r + 1]) >= min(a[l + 1], b[r]))) {
			++r;
		} else {
			++l;
		}
		ld cur = min(a[l], b[r]) - (l + r);
		ans = max(ans, cur);
	}
	cout << fixed << setprecision(4);
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 5 ms 2396 KB Output is correct
6 Correct 1 ms 2444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 5 ms 2396 KB Output is correct
6 Correct 1 ms 2444 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2548 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 5 ms 2396 KB Output is correct
6 Correct 1 ms 2444 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2548 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 63 ms 6784 KB Output is correct
18 Correct 56 ms 8020 KB Output is correct
19 Correct 56 ms 8016 KB Output is correct
20 Correct 56 ms 8024 KB Output is correct
21 Correct 60 ms 8516 KB Output is correct
22 Correct 60 ms 8276 KB Output is correct
23 Correct 55 ms 8028 KB Output is correct
24 Correct 55 ms 8060 KB Output is correct
25 Correct 55 ms 8028 KB Output is correct
26 Correct 59 ms 8312 KB Output is correct