Submission #231789

# Submission time Handle Problem Language Result Execution time Memory
231789 2020-05-14T18:58:57 Z nicolaalexandra Sure Bet (CEOI17_sure) C++14
100 / 100
225 ms 5416 KB
#include <bits/stdc++.h>
#define DIM 100010
using namespace std;
double a[DIM],b[DIM],sp_a[DIM],sp_b[DIM];
int n,i;

int main (){

    //ifstream cin ("date.in");
    //ofstream cout ("date.out");

    cin>>n;
    for (i=1;i<=n;i++)
        cin>>a[i]>>b[i];

    sort (a+1,a+n+1);
    reverse (a+1,a+n+1);

    sort (b+1,b+n+1);
    reverse (b+1,b+n+1);

    for (i=1;i<=n;i++){
        sp_a[i] = sp_a[i-1] + a[i];
        sp_b[i] = sp_b[i-1] + b[i];
    }

    /// fixez cat iau din prima
    double maxi = 0;
    for (i=1;i<=n;i++){
        double sum1 = sp_a[i] - i;

        int st = 1, dr = n;
        while (st <= dr){
            int mid = (st+dr)>>1;
            double val1 = min (sum1 - mid + 1, sp_b[mid-1] - i - mid + 1);
            double val2 = min (sum1 - mid, sp_b[mid] - i - mid);
            double val3 = min (sum1 - mid - 1, sp_b[mid+1] - i - mid - 1);

            if (val1 <= val2 && val2 >= val3){
                maxi = max (maxi,val2);
                break;
            }

            if (val2 <= val3)
                st = mid+1;
            else dr = mid-1;
        }
    }

    cout<<setprecision(4)<<fixed<<maxi;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 256 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 256 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 204 ms 4856 KB Output is correct
18 Correct 197 ms 4856 KB Output is correct
19 Correct 202 ms 4856 KB Output is correct
20 Correct 200 ms 4860 KB Output is correct
21 Correct 219 ms 5112 KB Output is correct
22 Correct 197 ms 4856 KB Output is correct
23 Correct 205 ms 4856 KB Output is correct
24 Correct 198 ms 4856 KB Output is correct
25 Correct 198 ms 4856 KB Output is correct
26 Correct 225 ms 5416 KB Output is correct