답안 #491002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491002 2021-11-30T03:13:19 Z kawaii Sure Bet (CEOI17_sure) C++14
100 / 100
107 ms 6712 KB
#include <bits/stdc++.h>
using namespace std; 
 
int n;
long double a[100005], b[100005], sum[100005], ans = 0; 

void solve(){  
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    for(int i = n; i >= 1; i--) sum[i] = sum[i + 1] + b[i];
    long double suma = 0;
    for(int i = n; i >= 1; i--){
        suma += a[i];
        int l = 0, r = n + 1;
        while(r - l > 1){
            int mid = (l + r) / 2;
            if(sum[mid] > suma) l = mid;
            else r = mid;
        }
        int num = (n - i + 1) + (n - r + 1);  
        ans = max(ans, min(suma, sum[r]) - num);
        ans = max(ans, min(suma, sum[r] + b[l]) - num - 1); 
    }
    cout << fixed << setprecision(4) << ans;
}
 
signed main(){  
    ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; 
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 93 ms 6340 KB Output is correct
18 Correct 98 ms 6372 KB Output is correct
19 Correct 93 ms 6368 KB Output is correct
20 Correct 103 ms 6372 KB Output is correct
21 Correct 107 ms 6708 KB Output is correct
22 Correct 91 ms 6264 KB Output is correct
23 Correct 92 ms 6340 KB Output is correct
24 Correct 92 ms 6332 KB Output is correct
25 Correct 96 ms 6380 KB Output is correct
26 Correct 99 ms 6712 KB Output is correct