Submission #609687

#TimeUsernameProblemLanguageResultExecution timeMemory
609687MasterTasterSure Bet (CEOI17_sure)C++14
60 / 100
99 ms3448 KiB
#include <bits/stdc++.h> #define pb push_back #define ll long long #define pii pair<int, int> #define xx first #define yy second #define MAXN 100010 #define double long double using namespace std; int n; double ress=0, a[MAXN], b[MAXN]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for (int i=0; i<n; i++) cin>>a[i]>>b[i]; sort(a, a+n, greater<double>()); sort(b, b+n, greater<double>()); double aa=0, bb=0; int i=0, j=0; while (i<n || j<n) { if (i==n || bb<aa) { bb+=b[j++]; } else if (j==n || aa<bb) { aa+=a[i++]; } else if (aa==bb) { if (a[i]>=b[j]) aa+=a[i++]; else bb+=b[j++]; } aa--; bb--; ress=max(ress, min(aa, bb)); } cout<<fixed<<setprecision(4)<<ress<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...