제출 #470572

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

using namespace std;

using ll  = long long;
using ld  = long double;
using vl  = vector<long long>;

#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin() , (x).end()

const ll MOD = 998244353;
const long double EPS = 0.000000001;
const double PI = 3.14159265358979323846;

const int nx[4]={0, 0, 1, -1}, ny[4]={1, -1, 0, 0};

int32_t main()
{
    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll n; cin>>n; vector<ld>a(n), b(n);
    for(int l=0;l<n;l++) cin>>a[l]>>b[l];
    sort(all(a)); sort(all(b));
    reverse(all(a)); reverse(all(b));
    vector<ld>head(n), tail(n);
    head[0]=a[0], tail[0]=b[0];
    for(int l=1;l<n;l++) head[l]=head[l-1]+a[l], tail[l]=tail[l-1]+b[l];
    int l=0, r=0; ld ans=0.0;
    while(l<n&&r<n) {
        ld x=head[l]-l-r-2;
        ld y=tail[r]-l-r-2;
        ans=max(ans, min(x, y));
        if(x<y) l++;
        else r++;
    }
    cout<<setprecision(4)<<fixed<<ans<<'\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...