답안 #987495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987495 2024-05-22T21:50:14 Z ErJ Sure Bet (CEOI17_sure) C++17
100 / 100
66 ms 3680 KB
#include <bits/stdc++.h>

#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<ll>
#define vvi vector<vi>
#define pp pair<ll,ll>
#define vp vector<pp>
#define vvp vector<vp>
#define inf 1000000000000000000
#define mod 1000000007

using namespace std;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> A(n), B(n);
    rep(i,n){
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int pocet = 0;
    double a = 0, b = 0;
    int ia = n - 1;
    int ib = n-1;
    double ans = 0;
    while(true){    
        if(a > b){
            if(ib < 0) break;
            pocet++;
            b += B[ib];
            ib--;
        }else{
            if(ia < 0) break;
            pocet++;
            a += A[ia];
            ia--;
        }
        ans = max(ans, min(a - pocet, b - pocet));
    }
    printf("%.4lf",(double)ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 57 ms 3164 KB Output is correct
18 Correct 57 ms 3384 KB Output is correct
19 Correct 58 ms 3432 KB Output is correct
20 Correct 57 ms 3156 KB Output is correct
21 Correct 66 ms 3664 KB Output is correct
22 Correct 57 ms 3384 KB Output is correct
23 Correct 58 ms 3384 KB Output is correct
24 Correct 57 ms 3164 KB Output is correct
25 Correct 57 ms 3152 KB Output is correct
26 Correct 62 ms 3680 KB Output is correct