Submission #891147

#TimeUsernameProblemLanguageResultExecution timeMemory
891147vjudge1Sure Bet (CEOI17_sure)C++17
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> using namespace std; #define x first #define y second #define ll long long #define ull unsigned long long #define ld long double #define pf push_front #define pb push_back #define mp make_pair #define all(v) v.begin(), v.end() void boost(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); return; } //ull binpow(ull p, int i){ // if(i==0) return 1; // else if(i==1) return p; // else if(i%2==0) return binpow(p*p,i/2); // else return binpow(p*p,i/2)*p; //} void solve(){ int n; cin>>n; ld a[n],b[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>()); ld ans=0; int p1=1,p2=1; ld suma=a[0],sumb=b[0]; while(p1<n&&p2<n){ if(suma>sumb){ sumb+=b[p2]; p2++; } else{ suma+=a[p1]; p1++; } ans=max(ans,min(suma,sumb)-p1-p2); } cout<<setprecision(15)<<ans; return; } int main(){ boost(); int t=1; // cin>>t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...