Submission #125455

#TimeUsernameProblemLanguageResultExecution timeMemory
125455figter001Sure Bet (CEOI17_sure)C++17
100 / 100
227 ms3996 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; int main(){ int n; cin>>n; vector<double> o[2]; for(int i=0;i<n;i++){ double a,b; cin>>a>>b; o[0].push_back(a); o[1].push_back(b); } sort(o[0].begin(),o[0].end()); sort(o[1].begin(),o[1].end()); double sum[2] = {0,0},ans = 0; int at1 = n-1,at2 = n-1; while(at1 != -1 || at2 != -1){ if(at1 == -1){ sum[1] += o[1][at2]; sum[1]--; sum[0]--; at2--; }else if(at2 == -1){ sum[0] += o[0][at1]; sum[0]--; sum[1]--; at1--; }else if(sum[0] < sum[1]){ sum[0] += o[0][at1]; sum[0]--; sum[1]--; at1--; }else{ sum[1] += o[1][at2]; sum[1]--; sum[0]--; at2--; } ans = max(ans,min(sum[0],sum[1])); } printf("%.4f\n",ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...