Submission #316765

#TimeUsernameProblemLanguageResultExecution timeMemory
316765LifeHappen__Sure Bet (CEOI17_sure)C++14
100 / 100
95 ms5244 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r){return l+rng()%(r-l+1);} #define forinc(a,b,c) for(int a=b, _c=c; a<=_c; ++a) #define fordec(a,b,c) for(int a=b, _c=c; a>=_c; --a) #define forv(a,b) for(auto &a:b) #define fasty ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) #define ar array #define ii pair<int,int> #define fi first #define se second #define pb push_back #define eb emplace_back #define all(a) begin(a),end(a) #define reset(f,x) memset(f,x,sizeof(f)) #define bit(x,i) (x>>(i-1)&1ll) #define on(x,i) (x|(1ll<<(i-1))) #define off(x,i) (x&~(1ll<<(i-1))) const int N=1e5+5; int n; double a[N],b[N],x[N],y[N]; int32_t main(){ fasty; cin>>n; forinc(i,1,n) cin>>a[i]>>b[i]; sort(a+1, a+n+1); reverse(a+1, a+n+1); sort(b+1, b+n+1); reverse(b+1, b+n+1); forinc(i,1,n){ x[i]=x[i-1]+a[i]; y[i]=y[i-1]+b[i]; } double ans=0; for(int i=1, j=1; i<=n; ++i){ while(j<n && y[j]<x[i]) j++; ans=max(ans, min(y[j],x[i])-i-j); } for(int i=1, j=1; i<=n; ++i){ while(j<n && x[j]<y[i]) j++; ans=max(ans, min(y[i],x[j])-i-j); } cout<<setprecision(4)<<fixed<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...