Submission #570762

#TimeUsernameProblemLanguageResultExecution timeMemory
570762choigameautohackrbSure Bet (CEOI17_sure)C++14
60 / 100
8 ms468 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long ll; typedef long double ld; const ll N=1e3+7; ld tmpA, tmpB, ans, a[N], b[N], PreA[N], PreB[N]; ll tmp, n; bool maximize(ld &a, ld b){ if (a<b){ a=b; return 1; } else return 0; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for (int i=1;i<=n;i++) cin>>a[i]>>b[i]; sort(a+1, a+1+n, greater<ld>()); sort(b+1, b+1+n, greater<ld>()); for (int i=1;i<=n;i++){ PreA[i]=PreA[i-1]+a[i]; PreB[i]=PreB[i-1]+b[i]; } for (int i=1;i<=n;i++) for (int j=0;j<=n;j++){ tmp=i+j; tmpA=PreA[i]-tmp; tmpB=PreB[j]-tmp; maximize(ans, min(tmpA, tmpB)); } cout<<fixed<<setprecision(4)<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...