제출 #278692

#제출 시각아이디문제언어결과실행 시간메모리
278692BeanZSure Bet (CEOI17_sure)C++14
100 / 100
132 ms5408 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define endl '\n'
const int N = 15;
long double a[100005], b[100005];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("VietCT.INP", "r")){
                freopen("VietCT.INP", "r", stdin);
                freopen("VietCT.OUT", "w", stdout);
        }
        ll n;
        cin >> n;
        for (int i = 1; i <= n; i++){
                cin >> a[i] >> b[i];
        }
        sort(a + 1, a + n + 1, greater<long double>());
        sort(b + 1, b + n + 1, greater<long double>());
        ll l = 1, r = 1;
        long double sum1 = a[1], sum2 = b[1];
        long double ans = 0;
        while (true){
                ans = max(ans, min(sum1, sum2) - (long double)(l + r));
                if (sum1 <= sum2 && l < n){
                        l++;
                        sum1 += a[l];
                } else if (r < n){
                        r++;
                        sum2 += b[r];
                } else {
                        break;
                }
        }
        cout << fixed << setprecision(4) << ans;
}
/*
*/

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

sure.cpp: In function 'int main()':
sure.cpp:13:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |                 freopen("VietCT.INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |                 freopen("VietCT.OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...