Submission #374732

#TimeUsernameProblemLanguageResultExecution timeMemory
374732YJUSure Bet (CEOI17_sure)C++14
100 / 100
146 ms5456 KiB
#include<bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef long double ld; const ll N=1e5+5; const ll MOD=1e9+7; #define REP(i,n) for(int i=0;i<n;++i) #define REP1(i,n) for(int i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second ll n; ld a,b,ans; priority_queue<ld> pqa,pqb; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n; REP1(i,n){ cin>>a>>b; pqa.push(a);pqb.push(b); } a=b=0; REP1(i,2*n){ if(pqa.empty()||pqb.empty()){ if(!pqa.empty()){ a+=pqa.top();pqa.pop(); }else{ b+=pqb.top();pqb.pop(); } }else{ if(a<=b){ a+=pqa.top();pqa.pop(); }else{ b+=pqb.top();pqb.pop(); } } ans=max(ans,min(a,b)-i); } cout<<fixed<<setprecision(4)<<ans<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...