Submission #577122

# Submission time Handle Problem Language Result Execution time Memory
577122 2022-06-14T06:48:49 Z andrei_boaca Sure Bet (CEOI17_sure) C++14
100 / 100
147 ms 3580 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
double a[100005],b[100005],ans;
int n;
int main()
{
    cin>>n;
    for(int 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(int i=1;i<=n;i++)
        a[i]+=a[i-1];
    for(int i=1;i<=n;i++)
        b[i]+=b[i-1];
    for(int i=1;i<=n;i++)
        {
            int st=1;
            int dr=n;
            int pozmin=n+1;
            while(st<=dr)
            {
                int mij=(st+dr)/2;
                if(b[mij]>=a[i])
                {
                    pozmin=mij;
                    dr=mij-1;
                }
                else
                    st=mij+1;
            }
            if(pozmin>n)
                continue;
            double x=a[i]-i-pozmin;
            ans=max(ans,x);
        }
    for(int i=1;i<=n;i++)
        {
            int st=1;
            int dr=n;
            int pozmin=n+1;
            while(st<=dr)
            {
                int mij=(st+dr)/2;
                if(a[mij]>=b[i])
                {
                    pozmin=mij;
                    dr=mij-1;
                }
                else
                    st=mij+1;
            }
            if(pozmin>n)
                continue;
            double x=b[i]-i-pozmin;
            ans=max(ans,x);
        }
    cout<<fixed<<setprecision(4)<<ans;
    return 0;
}
# 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 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 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 2 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 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 2 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 139 ms 1792 KB Output is correct
18 Correct 135 ms 3192 KB Output is correct
19 Correct 134 ms 3116 KB Output is correct
20 Correct 144 ms 3128 KB Output is correct
21 Correct 147 ms 3560 KB Output is correct
22 Correct 131 ms 3112 KB Output is correct
23 Correct 133 ms 3192 KB Output is correct
24 Correct 137 ms 3212 KB Output is correct
25 Correct 125 ms 3188 KB Output is correct
26 Correct 146 ms 3580 KB Output is correct