Submission #309782

#TimeUsernameProblemLanguageResultExecution timeMemory
309782spike1236Sure Bet (CEOI17_sure)C++14
100 / 100
351 ms3576 KiB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

const int MAXN = 1e5 + 10;
int n;
ld a[MAXN], b[MAXN];

ld ans;

void solve() {
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i] >> b[i];
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    reverse(a + 1, a + n + 1);
    reverse(b + 1, b + n + 1);
    for(int i = 1; i <= n; ++i) a[i] += a[i - 1], b[i] += b[i - 1];
    for(int i = 1; i <= n; ++i) a[i] -= i, b[i] -= i;
    for(int x = 0; x <= n; ++x) {
        ld l = 0, r = 1e9, res = 0;
        for(int test = 1; test <= 100; ++test) {
            ld mid = (l + r) / 2;
            int y = a[x] - mid;
            y = min(y, n);
            if(y >= 0 && b[y] - x >= mid) res = mid, l = mid;
            else r = mid;
        }
        ans = max(ans, res);
    }
    cout << fixed << setprecision(4) << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...