Submission #412446

#TimeUsernameProblemLanguageResultExecution timeMemory
412446PbezzSure Bet (CEOI17_sure)C++14
0 / 100
1 ms316 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define pb push_back #define mp make_pair typedef pair<ll,ll> pii; typedef tree<pii ,null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; const ll MAXN = 301; const ll MOD = 1e9+7; const ll INF = 1e6+10; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,i,x,y; double sx,sy,ans=0; cin>>n; double a[n],b[n]; for(i=0;i<n;i++){ cin>>a[i]>>b[i]; } sort(a,a+n,greater<double>()); sort(b,b+n,greater<double>()); x=0; y=0; sx=0; sy=0; for(i=0;i<2*n;i++){ if(sx<=sy && x!=n){ sx+=a[x]; x++; }else{ sy+=b[y]; y++; } //cout<<x<<" "<<y<<" "<<sx<<" "<<sy<<" "<<(double)(min(sx,sy)-(double)(x+y))<<endl; ans = max(ans, (double)(min(sx,sy)-(double)(x+y)) ); } //cout<<setprecision(5)<<ans<<endl; printf("%.4lf",(double)ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...