Submission #987410

#TimeUsernameProblemLanguageResultExecution timeMemory
987410ErJSure Bet (CEOI17_sure)C++17
100 / 100
118 ms3664 KiB
#include <bits/stdc++.h> #define ll long long #define rep(i,n) for(int i = 0; i < n; i++) #define vi vector<ll> #define vvi vector<vi> #define pp pair<ll,ll> #define vp vector<pp> #define vvp vector<vp> #define inf 1000000000000000000 #define mod 1000000007 using namespace std; int main() { int n; cin >> n; vector<double> A(n), B(n); rep(i,n){ cin >> A[i] >> B[i]; } sort(A.begin(), A.end()); sort(B.begin(), B.end()); int pocet = 0; double a = 0, b = 0; int ia = n - 1; int ib = n-1; double ans = 0; while(true){ if(a > b){ if(ib < 0) break; pocet++; b += B[ib]; ib--; }else{ if(ia < 0) break; pocet++; a += A[ia]; ia--; } ans = max(ans, min(a - pocet, b - pocet)); } printf("%.4lf",(double)ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...