답안 #1027317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027317 2024-07-19T03:36:51 Z BuzzyBeez Sure Bet (CEOI17_sure) C++17
100 / 100
69 ms 2020 KB
#include <bits/stdc++.h>
using namespace std;

const int buff = 100000;
const long double dick = 1.0;

long long A[100008], B[100008];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; long double x; cin >> n;
	cout << fixed << setprecision(4);
	for (int i = 1; i <= n; ++i) {
		cin >> x; A[i] = round(x * buff);
		cin >> x; B[i] = round(x * buff);
	}
	sort(A + 1, A + n + 1, greater<long long>()); sort(B + 1, B + n + 1, greater<long long>());
	for (int i = 1; i <= n; ++i) A[i] += A[i - 1];
	for (int i = 1; i <= n; ++i) B[i] += B[i - 1];
	int j; long double ans = 0;
	for (int i = 1; i <= n && A[i] <= B[n]; ++i) { // A[i] <= B[j]
		j = lower_bound(B + 1, B + n + 1, A[i]) - B;
		// cout << (A[i] * dick) / buff - i - j << '\n';
		ans = max(ans, (A[i] * dick) / buff - i - j);
	}
	for (int i = 1; i <= n && B[i] <= A[n]; ++i) { // B[i] <= A[j]
		j = lower_bound(A + 1, A + n + 1, B[i]) - A;
		ans = max(ans, (B[i] * dick) / buff - i - j);
		// cout << (B[i] * dick) / buff - i - j << '\n';
	} 
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 488 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 488 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 59 ms 1872 KB Output is correct
18 Correct 59 ms 1872 KB Output is correct
19 Correct 57 ms 1876 KB Output is correct
20 Correct 55 ms 1876 KB Output is correct
21 Correct 60 ms 1872 KB Output is correct
22 Correct 57 ms 2020 KB Output is correct
23 Correct 64 ms 1872 KB Output is correct
24 Correct 57 ms 1872 KB Output is correct
25 Correct 54 ms 1804 KB Output is correct
26 Correct 69 ms 1872 KB Output is correct