Submission #94246

#TimeUsernameProblemLanguageResultExecution timeMemory
942461KhanSure Bet (CEOI17_sure)C++14
0 / 100
3 ms376 KiB
/// 1n  the  name  of  GOD

#include <bits/stdc++.h>

using   namespace        std;

#define ko               exit(0);
#define nl               '\n'
#define ios              ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz(s)            (int)s.size()
#define all(s)           s.begin(), s.end()
#define oll(s, n, c)     (s) + (c), s + (n) + c
#define pb               push_back
#define bb               begin()
#define ee               end()
#define ff               first
#define ss               second
#define pii              pair<int, int>
//#define for(i, l, r)  for(int (i) = (l); i <= (r); ++i)

typedef long long ll;
typedef double db;

const int N = 1e5 + 777;
const int M = INT_MAX;

int n;
double a[N], b[N];
double c, d;
int main(){

     ios

     cin >> n;
     for(int i = 1; i <= n; ++i){
          cin >> a[i] >> b[i];
     }
     sort(oll(a, n, 1));
     sort(oll(b, n, 1));
     reverse(oll(a, n, 1));
     reverse(oll(b, n, 1));
     int id = 1;
     int di = 1;
     double ans = 0;
     c += a[1];
     d += b[1];
     ans = max(ans, min(c - (double)2, d - (double)2));
     while(id <= n && di <= n){
          while(d > c){
               id++;
               c += a[id];
               ans = max(ans, min(c - (double)(id + di), d - (double)(di + id)));
          }
          while(d < c){
               di++;
               d += b[di];
               ans = max(ans, min(c - (double)(id + di), d - (double)(di + id)));
          }
          if(d == c){
               id++;
               di++;
               c += a[id];
               d += b[di];
               ans = max(ans, min(c - (double)(id + di), d - (double)(di + id)));

          }
     }
     cout << fixed << setprecision(4) << (double)ans;
     return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...