Submission #124553

# Submission time Handle Problem Language Result Execution time Memory
124553 2019-07-03T13:46:17 Z semiauto Sure Bet (CEOI17_sure) C++14
100 / 100
231 ms 5232 KB
#include <bits/stdc++.h>
using namespace std;
int n,i,j,pos;
double s,ans;
double a[100001],b[100001],sum[100001],pre[100001];
int main() {
    cin>>n;
    for (i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    for (i=1;(2*i)<=n;i++) {
        swap(a[i],a[n-i+1]);
        swap(b[i],b[n-i+1]);
    }
    for (i=1;i<=n;i++) {
        sum[i]=sum[i-1]+b[i];
        pre[i]=max(pre[i-1],sum[i]-i);
    }
    for (i=1;i<=n;i++) {
        s+=a[i];
        pos=0;
        for (j=20;j>=0;j--) {
            if (pos+(1<<j)>n)
                continue;
            if (sum[pos+(1<<j)]<=s)
                pos+=(1<<j);
        }
        if (pos>0)
            ans=max(ans,pre[pos]-i);
        if (pos<n)
            ans=max(ans,s-pos-1-i);
    }
    printf("%.4f\n",ans);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 296 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 296 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
17 Correct 196 ms 4828 KB Output is correct
18 Correct 200 ms 4836 KB Output is correct
19 Correct 199 ms 4908 KB Output is correct
20 Correct 197 ms 4856 KB Output is correct
21 Correct 231 ms 5232 KB Output is correct
22 Correct 196 ms 4856 KB Output is correct
23 Correct 196 ms 4856 KB Output is correct
24 Correct 221 ms 4820 KB Output is correct
25 Correct 197 ms 4800 KB Output is correct
26 Correct 229 ms 5112 KB Output is correct