Submission #246448

#TimeUsernameProblemLanguageResultExecution timeMemory
246448uacoder123Sure Bet (CEOI17_sure)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int test=1; for(;test>0;--test) { float n,ans=0; cin>>n; int k=-1; vector<float> f(n),s(n); for(int i=0;i<n;++i) cin>>f[i]>>s[i]; sort(all(f),greater<float>()); sort(all(s),greater<float>()); if(k==-1&&s[0]<1) k=0; for(int i=1;i<n;++i) { if(k==-1&&s[i]<1) k=i; f[i]=f[i]+f[i-1]; s[i]=s[i]+s[i-1]; } if(k==-1) k=n; for(int i=0;i<n;++i) { lli j=lower_bound(all(s),f[i])-s.begin(); if(k<=j&&j!=n) { ans=max(ans,min(f[i]-i-1-j-1,s[j]-i-1-j-1)); } j=min(j,k*1LL); if(j==n) j=n-1; ans=max(ans,min(f[i]-i-1-j-1,s[j]-i-1-j-1)); } cout<<fixed<<setprecision(4)<<ans<<endl; } return(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...