제출 #1028364

#제출 시각아이디문제언어결과실행 시간메모리
1028364vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
84 ms3576 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<ld,ld> #define fi first #define se second #define endl "\n" #define rep(a,b,c) for(ll a=b; a<c; a++) #define rep2(a,b,c,d) for(ll a=b; a<c; a+=d) #define repr(a,b,c) for(ll a=b-1; a>c-1; a--) #define repa(a,b) for(const auto &a: b) #define multicase() int t; cin>>t; while(t--) #define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define valid(c) cout<<(c ? "YES" : "NO")<<endl; #define valid2(c,a,b) cout<<(c ? a : b)<<endl; #define ll long long #define ld long double #define pq_min(a) priority_queue<a, vector<a>, greater<a>> #define pq_max(a) priority_queue<a> #define pb push_back using namespace std; int main(){ fastIO(); cout<<setprecision(4)<<fixed<<endl; int n; cin>>n; ld a[n+5]{}, b[n+5]{}, ans=0; int l, r, mid; rep(i,1,n+1) cin>>a[i]>>b[i]; sort(a+1,a+n+1); sort(b+1,b+n+1); reverse(a+1,a+n+1); reverse(b+1,b+n+1); rep(i,1,n+1) a[i]+=a[i-1], b[i]+=b[i-1]; rep(i,1,n+1){ l=1; r=n; while(l<=r){ mid=(l+r)>>1; if(b[mid]<=a[i]) l=mid+1; else r=mid-1; } ans=max(ans,max(min(a[i],b[l])-i-l,min(a[i],b[r])-i-r)); } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...