답안 #927931

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927931 2024-02-15T14:10:38 Z TAhmed33 Sure Bet (CEOI17_sure) C++
100 / 100
134 ms 6740 KB
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
int n;
ld a[100001];
ld b[100001];
ld pref[100001];
int main () {
    cin >> n;
    for (int i = 1; i <= n; i++) {
	    cin >> a[i] >> b[i];
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    reverse(a + 1, a + n + 1);
    reverse(b + 1, b + n + 1);
    ld mx = 0;
    for (int i = 2; i <= n; i++) {
	    a[i] += a[i - 1];
	    b[i] += b[i - 1];
    }
    pref[1] = a[1] - 1;
    for (int i = 2; i <= n; i++) {
	    pref[i] = max(pref[i - 1], a[i] - i);
    }
    for (int i = 1; i <= n; i++) {
    	int l = 1, r = n, ans = -1;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (a[mid] < b[i]) {
			l = mid + 1;
		} else {
			r = mid - 1; ans = mid;
		}
	}
	if (ans != -1) {
		mx = max(mx, b[i] - i - ans);
		if (ans != -1) mx = max(mx, pref[ans - 1] - i);		
	} else {
		mx = max(mx, pref[n] - i);
	}
    }
    cout << fixed << setprecision(4) << mx << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 2 ms 4444 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4444 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 2 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 2 ms 4444 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4444 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 2 ms 4440 KB Output is correct
17 Correct 114 ms 6484 KB Output is correct
18 Correct 110 ms 6336 KB Output is correct
19 Correct 111 ms 6480 KB Output is correct
20 Correct 118 ms 6480 KB Output is correct
21 Correct 124 ms 6736 KB Output is correct
22 Correct 110 ms 6480 KB Output is correct
23 Correct 115 ms 6484 KB Output is correct
24 Correct 134 ms 6376 KB Output is correct
25 Correct 109 ms 6340 KB Output is correct
26 Correct 129 ms 6740 KB Output is correct