Submission #865230

#TimeUsernameProblemLanguageResultExecution timeMemory
865230vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
77 ms6796 KiB
// Bolatulu #include <bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef double db; #define int long long #define kanagattandirilmagandiktarinizdan ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); #define pb push_back #define F first #define S second #define md (tl+tr)/2 #define TL v+v,tl,mid #define TR v+v+1,mid+1,tr #pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") using namespace std; int binpow(int a,int n,int M) { if (n==0) return 1; if (n%2!=0) return (a * binpow(a,n-1,M))%M; int z=binpow(a,n/2,M); return (z*z)%M; } const ll INF = 1e18; const int N = 1e6+7; const int M = 1e9+7; const ll HZ = 1e5; const int MAX = INT_MAX; const int MIN = INT_MIN; const db pi = 3.141592653; const int P=31; int n; db a[N],b[N],ans; void solve() { cin >> n; for (int i=1;i<=n;i++) cin >> a[i] >> b[i]; sort (a+1,a+n+1), sort (b+1,b+n+1); int i=n,j=n,cnt=0; db sum1=0,sum2=0; while (i>0 or j>0) { while (i>0 and (sum1<=sum2 or j==0)) { sum1+=a[i]; i--, cnt++; ans=max(ans,min(sum1,sum2)-cnt); } while (j>0 and (sum2<=sum1 or i==0)) { sum2+=b[j]; j--, cnt++; ans=max(ans,min(sum1,sum2)-cnt); } } printf("%.4lf",(double)ans); } signed main() { // freopen("lca.in", "r", stdin); // freopen("lca.out", "w", stdout); kanagattandirilmagandiktarinizdan int test = 1, count = 1; // cin >> test; while (test--) { // cout << "Case " << count << ":\n"; solve(); if (test) // cout << '\n'; count++; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...