Submission #425653

# Submission time Handle Problem Language Result Execution time Memory
425653 2021-06-13T09:47:25 Z oleh1421 Sure Bet (CEOI17_sure) C++17
100 / 100
123 ms 5264 KB
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=100010;
const ll mod=1000000007;
const ll inf=1e15;
double a[N],b[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    vector<double>v;
    for (int i=1;i<=n;i++) {
        cin>>a[i]>>b[i];
        v.push_back(a[i]);
        v.push_back(b[i]);
    }
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    reverse(a+1,a+n+1);
    reverse(b+1,b+n+1);
    for (int i=2;i<=n;i++) a[i]+=a[i-1];
    for (int i=2;i<=n;i++) b[i]+=b[i-1];
    double res=0.0;
    for (int len=1;len<=2*n;len++){
        int l=max(0,len-n);
        int r=min(n,len);
        int pos=l;
        for (int i=20;i>=0;i--){
            if (pos+(1<<i)<=r && a[pos+(1<<i)]<=b[len-pos-(1<<i)]) pos+=(1<<i);
        }
        for (int i=pos;i<=min(r,pos+1);i++){
            int j=len-i;
            res=max(res,min(a[i]-len,b[j]-len));
        }
    }
    cout<<setprecision(4)<<fixed<<res<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 114 ms 4972 KB Output is correct
18 Correct 113 ms 4916 KB Output is correct
19 Correct 114 ms 4948 KB Output is correct
20 Correct 115 ms 4860 KB Output is correct
21 Correct 120 ms 5264 KB Output is correct
22 Correct 111 ms 4916 KB Output is correct
23 Correct 110 ms 4920 KB Output is correct
24 Correct 112 ms 4936 KB Output is correct
25 Correct 112 ms 4936 KB Output is correct
26 Correct 123 ms 5208 KB Output is correct