답안 #1112635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1112635 2024-11-14T13:07:58 Z sunboi Sure Bet (CEOI17_sure) C++17
100 / 100
126 ms 5192 KB
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
 

 
signed main(){
    double n; cin >> n;
    vector<double> a(n + 1), b(n + 1), pref(n + 1), prefb(n + 1);
    a[0] = 1e9;
    b[0] = 1e9;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        cin >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    a[0] = 0;
    b[0] = 0;
    for (int i = 1; i <= n; i++){
        pref[i] = pref[i - 1] + a[i];
        prefb[i] = prefb[i - 1] + b[i];
    }
    
    double ans = 0;
    int i = 0, j = 0;
    for (double monedas = 1; monedas <= 2 * n; monedas++){
        //cout << i << ' ' << j << endl;
        if (i == n && j == n) break;
        if (i == n){
            ans = max(ans, min(pref[i] - monedas, prefb[j + 1] - monedas));
            j++;
        }else if (j == n){
            ans = max(ans, min(pref[i + 1] - monedas, prefb[j] - monedas));
            i++;
        }else{
            if (min(pref[i + 1] - monedas, prefb[j] - monedas) >= min(pref[i] - monedas, prefb[j + 1] - monedas)){
                ans = max(ans, min(pref[i + 1] - monedas, prefb[j] - monedas));
                i++;
            }else{
                ans = max(ans, min(pref[i] - monedas, prefb[j + 1] - monedas));
                j++;
            }
        }
        
        
        
    }
    printf("%.4lf",(double)ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 84 ms 3408 KB Output is correct
18 Correct 80 ms 4936 KB Output is correct
19 Correct 81 ms 4936 KB Output is correct
20 Correct 82 ms 4836 KB Output is correct
21 Correct 126 ms 5192 KB Output is correct
22 Correct 80 ms 4708 KB Output is correct
23 Correct 95 ms 5192 KB Output is correct
24 Correct 80 ms 4704 KB Output is correct
25 Correct 80 ms 4704 KB Output is correct
26 Correct 113 ms 5192 KB Output is correct