Submission #361628

#TimeUsernameProblemLanguageResultExecution timeMemory
361628bigDuckSure Bet (CEOI17_sure)C++14
100 / 100
95 ms3728 KiB
#include<bits/stdc++.h> using namespace std; #define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define mp make_pair #define pb push_back #define ft first #define sc second #define ll long long #define pii pair<int, int> #define count_bits __builtin_popcount #define int ll int t, n, m, k, a[300010], l, r; int b[100010]; int q=1000000000; int32_t main(){ INIT cin>>n; for(int i=1; i<=n; i++){ long double d, c; cin>>c>>d; a[i]=c*q; if( (a[i]%(q/10000))>0 ){ a[i]=a[i]-(a[i]%(q/10000))+(q/10000); } b[i]=d*q; if( (b[i]%(q/10000))>0 ){ b[i]=b[i]-(b[i]%(q/10000))+(q/10000); } } sort(b+1, b+1+n); sort(a+1, a+1+n); int j=0; int s1=0, s2=0; int res=0; for(int i=1; i<=n; i++){ s1+=a[n-i+1]; res=max(res, min(s1,s2)-(i+j)*q); while( (s2<s1) && (j<n) ){ res=max(res, min(s1, s2)-(i+j)*q); j++; s2+=b[n-j+1]; res=max(res, min(s1,s2)-(i+j)*q); } res=max(res, min(s1,s2)-(i+j)*q); } double a=res, b=q; cout<<fixed<<setprecision(4)<<(a/b); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...