Submission #1027454

#TimeUsernameProblemLanguageResultExecution timeMemory
1027454anHiepSure Bet (CEOI17_sure)C++14
0 / 100
1 ms4440 KiB
#include<bits/stdc++.h> #ifdef LOCAL #include "D:\debug.h" #else #define cebug(...) "Orz_chUoNgnn_khanhtb_0x2ee08" #endif using namespace std; #define fi first #define se second #define pb push_back #define ll long long #define ii pair<int, int> #define vi vector<int> #define vll vector<ll> #define vii vector<ii> #define cd complex<double> #define ld long double const ll mod = 1e9 + 7; const ll INF = 1e18L + 5; const double PI = acos(-1); const int block = 320; const int N = 2e5; int tc, tt = 1; int n; ld a[N + 5], b[N + 5]; ld f[N + 5]; ld eps = 0.000000001; void solve() { cin>>n; for(int i=1; i<=n; i++) cin>>a[i]>>b[i]; ld ans = 0; sort(a + 1, a + 1 + n, greater<ld>()); sort(b + 1, b + 1 + n, greater<ld>()); for(int l=1; l<=2; l++) { for(int i=1; i<=n; i++) f[i] = f[i - 1] + b[i]; ld sum = 0; for(int i=1; i<=n; i++) { sum += a[i]; ld mi = 1e9; int l = 1, r = n; while(l <= r) { int mid = (l + r)/2; if(f[mid] - sum >= 0.0) { mi = mid; r = mid - 1; } else l = mid + 1; } ans = max(ans, sum - i - mi); } for(int i=1; i<=n; i++) swap(a[i], b[i]); } cout<<fixed<<setprecision(9)<<ans; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); for(tc=1; tc<=tt; tc++) solve(); cerr<<"\nTime elapsed: "<<1000.0*clock()/CLOCKS_PER_SEC<<" ms.\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...