Submission #928405

# Submission time Handle Problem Language Result Execution time Memory
928405 2024-02-16T10:33:27 Z Aiperiii Sure Bet (CEOI17_sure) C++14
100 / 100
123 ms 5228 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
signed main(){
    int n;
    cin>>n;
    vector <long double> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
    }
    sort(all(a));sort(all(b));
    reverse(all(a));reverse(all(b));
    long double p1=0,p2=0;
    long double sum1=0,sum2=0;
    long double ans=0;
    while(p1<n){
        sum1+=a[p1];
        p1++;
        while(min(sum1-p2,sum2-p1)<=min(sum1-p2-1,sum2+b[p2]-p1) && p2<n){
            sum2+=b[p2];
            p2++;
        }
        ans=max(ans,min(sum1-p2,sum2-p1));
    }
    cout<<fixed<<setprecision(4)<<ans<<"\n";
}
/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
 */
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 444 KB Output is correct
17 Correct 106 ms 4424 KB Output is correct
18 Correct 108 ms 4828 KB Output is correct
19 Correct 108 ms 4712 KB Output is correct
20 Correct 106 ms 4828 KB Output is correct
21 Correct 121 ms 5092 KB Output is correct
22 Correct 106 ms 4880 KB Output is correct
23 Correct 106 ms 4708 KB Output is correct
24 Correct 114 ms 4932 KB Output is correct
25 Correct 123 ms 4692 KB Output is correct
26 Correct 122 ms 5228 KB Output is correct