제출 #281835

#제출 시각아이디문제언어결과실행 시간메모리
281835nekiSure Bet (CEOI17_sure)C++14
60 / 100
5 ms640 KiB
#include <bits/stdc++.h> //#include "icc.h" #define loop(i, a, b) for(long long i=a;i<b;i++) #define pool(i, a, b) for(long long i=a-1;i>=b;i--) #define fore(i, a) for(auto&& i:a) #define fi first #define se second #define ps(a) push_back(a) #define vc vector #define pa pair<ll, ll> #define ll long long #define all(a) a.begin(), a.end() using namespace std; #define mn 2010 #define pa pair<ll, ll> #define ld long double ld a[mn], b[mn]; ld min(ld a, ld b){return (a<b) ? a:b;} ld max(ld a, ld b){return (a>b) ? a:b;} int main(){ ll n;cin >> n; loop(i, 1, n+1) cin >> a[i]>>b[i]; sort(a+1, a+n+1, greater<ld> ()); loop(i, 1, n+1) a[i]+=a[i-1]; sort(b+1, b+n+1, greater<ld> ()); loop(i, 1, n+1) b[i]+=b[i-1]; ld ans=0.0; ll j=0; loop(i, 0, n+1){ while(j<n and min(a[i], b[j])-(ld)i-(ld)j<=min(a[i], b[j+1])-(ld)i-(ld)j-(ld)1) j++; ans=max(ans, min(a[i], b[j])-(ld)i-(ld)j); } cout << fixed << setprecision(4)<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...