답안 #657471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657471 2022-11-09T23:40:59 Z perchuts Sure Bet (CEOI17_sure) C++17
100 / 100
86 ms 3816 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define endl '\n'
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
 
using namespace std;
 
using ii = pair<int,int>;
using iii = tuple<int,int,int>;
using ll = long long;
 
const int inf = 1e9+1;
const int mod = 1e9+7;
const int maxn = 1e5+100;
 
template<typename X,typename Y> bool ckmin(X& x,Y y){return (x>y?x=y,1:0);}
template<typename X,typename Y> bool ckmax(X& x,Y y){return (x<y?x=y,1:0);}
 
int main(){_
    int n;cin>>n;
    vector<double>a, b;
    for(int i=1;i<=n;++i){
        double x,y;cin>>x>>y;
        a.pb(x), b.pb(y);
    }
 
    sort(all(a), greater<double>());
    sort(all(b), greater<double>());
 
    for(int i=1;i<n;++i)a[i] += a[i-1];
    double cur = 0, ans = 0;
 
    for(int i=0;i<n;++i){//take i+1 bets on b
        cur += b[i];
        int l = 0, r = n-1;
        while(l<r){//primeira vez que esq >= dir
            int md = (l+r)/2;
            if(a[md]>=cur)r = md;
            else l = md+1;
        }
        ckmax(ans, min(a[r], cur)-r-i-2);
        if(r)ckmax(ans, min(a[r-1], cur)-r-i-1);
    }
 
    cout<<fixed<<setprecision(4)<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 77 ms 3360 KB Output is correct
18 Correct 73 ms 3380 KB Output is correct
19 Correct 79 ms 3420 KB Output is correct
20 Correct 79 ms 3376 KB Output is correct
21 Correct 84 ms 3760 KB Output is correct
22 Correct 79 ms 3396 KB Output is correct
23 Correct 81 ms 3388 KB Output is correct
24 Correct 86 ms 3356 KB Output is correct
25 Correct 80 ms 3444 KB Output is correct
26 Correct 83 ms 3816 KB Output is correct