답안 #973368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973368 2024-05-01T20:42:52 Z AtabayRajabli Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
#define int ll
#define all(v) v.begin(), v.end()
 
// author : a1abay
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
const int sz = 1e5 + 5;
const int inf = 1e9 + 7;
 
int n;
ld a[sz], b[sz];
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n;
    vector<pair<ld, bool>> v;
    ld l = 0, r = 0;
    for(int i = 1; i <= n; i++) 
    {
        cin >> a[i] >> b[i];
        v.push_back({a[i], 0});
        v.push_back({b[i], 1});
    }
    sort(v.begin(), v.end());
    ld x = 0, ans = 0;
    while(!v.empty())
    {
        ld val = v.back().first;
        bool c = v.back().second;
        v.pop_back();
        if(l <= r && !c) l += val, x++;
        else if(r <= l && c) r += val, x++;
        ans = max(ans, min(l - x, r - x));
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -