Submission #843022

# Submission time Handle Problem Language Result Execution time Memory
843022 2023-09-03T14:44:53 Z Mr_Ph Sure Bet (CEOI17_sure) C++14
100 / 100
67 ms 3664 KB
///Never gonna give you up.
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
const ll mod=(ll)1e9+7;
const ll mod1=998244353;
///the defines :)
#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
#define int long long
void preprocess() {}
void solve()
{
    int n;
    cin>>n;
    vector<double> arr1(n);
    vector<double> arr2(n);
    for(int i=0; i<n; i++)
        cin>>arr1[i]>>arr2[i];
    sort(allr(arr2));
    sort(allr(arr1));
    double ansa=0.0,ansb=0.0,ans=0.0;
    int j=0;
    for(int i=0; i<n; i++)
    {
        ansa+=(arr1[i]-1.0);
        ansb-=1.0;
        while(j<n&&(ansa>=ansb))
        {
            //   cout<<ansa<<" "<<ansb<<endl;
            ans=max(ans,min(ansa,ansb));
            ansb+=arr2[j]-1.0;
            ansa-=1.0;
            j++;
        }
        //  cout<<ansa<<" "<<ansb<<endl;
        ans=max(ans,min(ansa,ansb));
    }
    cout<<fixed<<setprecision(4)<<ans<<endl;
}
signed main()
{
    // freopen("div7.in","r",stdin);
    //freopen("div7.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    preprocess();
    //bla();
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}
# 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 0 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 0 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 1 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 0 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 1 ms 348 KB Output is correct
16 Correct 1 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 0 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 1 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 0 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 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 56 ms 1884 KB Output is correct
18 Correct 58 ms 3152 KB Output is correct
19 Correct 58 ms 3380 KB Output is correct
20 Correct 58 ms 3376 KB Output is correct
21 Correct 62 ms 3664 KB Output is correct
22 Correct 67 ms 3388 KB Output is correct
23 Correct 57 ms 3292 KB Output is correct
24 Correct 57 ms 3388 KB Output is correct
25 Correct 61 ms 3160 KB Output is correct
26 Correct 60 ms 3664 KB Output is correct