제출 #1353532

#제출 시각아이디문제언어결과실행 시간메모리
1353532goulthenSure Bet (CEOI17_sure)C++20
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,a,b) for (int i = a; i >= b; i--)
#define pii pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(), (v).end()

const int MAXN = 5e5+10;
const int INF = 1e18+10;
const int MOD = 1e9+7;
float a[MAXN], b[MAXN];

void solve() {
    int n; cin >> n;
    rep(i,1,n) {
        cin >> a[i] >> b[i];
    }
    sort(a+1,a+n+1, greater<float>());
    sort(b+1,b+n+1, greater<float>());
    rep(i,1,n) a[i] += a[i-1];
    rep(i,1,n) b[i] += b[i-1];
    float ans = 0;
    rep(x,1,n) {
        rep(y,1,n) {
            float x1 = a[x],x2 = b[y];
            ans = max(ans,min(x2, x1)-x-y);
        }
    }

    cout << (float)ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
	int tt = 1;
    //cin >> tt;
    
    while(tt--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...