Submission #561208

# Submission time Handle Problem Language Result Execution time Memory
561208 2022-05-12T13:08:52 Z NintsiChkhaidze Sure Bet (CEOI17_sure) C++14
100 / 100
89 ms 5248 KB
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define s second
#define f first
#define left (h<<1),l,(l+r)>>1
#define right ((h<<1)|1),((l+r)>>1) + 1,r
using namespace std;
 
const int N = 100005;
double a[N],b[N],A[N],B[N];

signed main (){
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n;
    cin>>n;
    
    for (int i = 1; i <= n; i++)
        cin>>a[i]>>b[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    
    for (int i = n; i >= 1; i--){
        A[i] = A[i + 1] + a[i];
        B[i] = B[i + 1] + b[i];
    }
    double ans = 0.0;
    for (int i = n; i >= 1; i--){
        int l = 1,r = n,res=0;
        while(l <= r){
            int mid = (l+r)>>1;
            if (B[mid] >= A[i]) {
                res = mid;
                l = mid + 1;
            }else{
                r = mid - 1;
            }
        }
        int tot = 2*n - i + 2 - res;
        if (res && A[i] - tot > ans)
            ans = A[i] - tot;
    }
    for (int i = n; i >= 1; i--){
        int l = 1,r = n,res=0;
        while(l <= r){
            int mid = (l+r)>>1;
            if (A[mid] >= B[i]) {
                res = mid;
                l = mid + 1;
            }else{
                r = mid - 1;
            }
        }
        int tot = 2*n - i + 2 - res;
        if (res && B[i] - tot > ans)
            ans = B[i] - tot;
    }
    printf("%.4f",ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 83 ms 3664 KB Output is correct
18 Correct 82 ms 4756 KB Output is correct
19 Correct 82 ms 4844 KB Output is correct
20 Correct 86 ms 4776 KB Output is correct
21 Correct 87 ms 5136 KB Output is correct
22 Correct 83 ms 4808 KB Output is correct
23 Correct 82 ms 4764 KB Output is correct
24 Correct 83 ms 4796 KB Output is correct
25 Correct 79 ms 4684 KB Output is correct
26 Correct 89 ms 5248 KB Output is correct