Submission #659555

# Submission time Handle Problem Language Result Execution time Memory
659555 2022-11-18T13:43:59 Z jiahng Sure Bet (CEOI17_sure) C++14
100 / 100
161 ms 5184 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 2000010
#define INF (ll)1e18
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;


int N;
double A[maxn],B[maxn];
double a,b;
double ssA[maxn], ssB[maxn];
int32_t main(){
    cin >> N;
    FOR(i,1,N){
        cin >> A[i] >> B[i];
    }
    sort(A+1,A+N+1,greater <double>()); sort(B+1,B+N+1,greater <double>());
    FOR(i,1,N) ssA[i] = ssA[i-1] + A[i];
    FOR(i,1,N) ssB[i] = ssB[i-1] + B[i];
    double ans = 0;
    FOR(i,1,N){
        int y = lower_bound(ssB+1,ssB+N+1,ssA[i]) - ssB;
        if (y == N+1) continue;
        ans = max(ans, ssA[i] - (i + y));
    }
    FOR(i,1,N){
        int x = lower_bound(ssA+1,ssA+N+1,ssB[i]) - ssA;
        if (x == N+1) continue;
        ans = max(ans, ssB[i] - (i + x));
    }
    printf("%.4lf", (double)ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 133 ms 4784 KB Output is correct
18 Correct 161 ms 4760 KB Output is correct
19 Correct 141 ms 4780 KB Output is correct
20 Correct 130 ms 4812 KB Output is correct
21 Correct 160 ms 5184 KB Output is correct
22 Correct 131 ms 4780 KB Output is correct
23 Correct 132 ms 4792 KB Output is correct
24 Correct 141 ms 4728 KB Output is correct
25 Correct 141 ms 4708 KB Output is correct
26 Correct 150 ms 5092 KB Output is correct