제출 #1225782

#제출 시각아이디문제언어결과실행 시간메모리
1225782theiuliusSure Bet (CEOI17_sure)C++20
0 / 100
0 ms320 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
// #define endl "\n"
int n;

main(){
    /*ifstream cin(".in");
    ofstream cout(".out");*/
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;
    float a[n] = {}, b[n] = {};
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    
    sort(a, a + n, greater<float>()); 
    sort(b, b + n, greater<float>());
    float pre[n] = {b[0]};
    int nd = n;
    for (int i = 1; i < n; i++){
        if (b[i] < 1 && nd == n){
            nd = i;
        }
        pre[i] = pre[i - 1] + b[i];
    }

    float left = 0, res = (float)0;
    for (int i = 0; i < n; i++){
        left += a[i];
        if (a[i] < 1){
            break;
        }
        
        int l = 0, r = nd - 1, ans = nd - 1;
        while (l <= r){
            int mid = (l + r) / 2;
            
            float right = pre[mid];
            
            if (right >= left){
                ans = mid;
                r = mid - 1;
            }else{
                l = mid + 1;
            }
        }
        
        res = max(res, (float)min(pre[ans] - (float)ans - (float)i - 2.0, (float)left - (float)ans - (float)i - 2.0));
        // cout << (float)left - (float)ans - (float)i - 2.0 << endl;
        if (ans){
            ans -= 1.0;
            res = max(res, (float)min(pre[ans] - (float)ans - (float)i - 2.0, (float)left - (float)ans - (float)i - 2.0));
        }
    }
    
    cout << res << endl;
}

컴파일 시 표준 에러 (stderr) 메시지

sure.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...