Submission #1027362

# Submission time Handle Problem Language Result Execution time Memory
1027362 2024-07-19T04:13:10 Z hehebjp123 Sure Bet (CEOI17_sure) C++14
100 / 100
172 ms 2788 KB
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,O3,unroll-loops")
#define ll long long
#define fi first
#define se second
#define ii pair<ll,ll>
#define pb push_back
using namespace std;
const ll N=2e5+5;
const long long mod=1e9+7;
const double esp=1e-8;
double a[N],b[N];
ll vta,vtb,i,j,n;
bool kt(double k)
{
    for(ll i=1;i<=n;i++)
    if(a[i]>=k)
    {
    ll l=1,r=n,vt;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(b[mid]-i>=k)
        {
            r=mid-1;
         if(a[i]-mid>=k)
            return 1;
        }
        else l=mid+1;
    }
    }
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a+1,a+n+1,greater<double>());
    sort(b+1,b+n+1,greater<double>());
    a[1]-=1;
    b[1]-=1;
    for(i=2;i<=n;i++)
    {
        a[i]+=a[i-1]-1;
        b[i]+=b[i-1]-1;
    }
    //return cout<<kt(0.5),0;
    double l=0,r=1e8,kq=0;
    while(l<=r-esp)
    {
        double mid=(l+r)/2;
       // cout<<l<<" "<<r<<" "<<mid<<'\n';
        if(kt(mid))
        {
            kq=mid;
            l=mid+esp;
        }
        else r=mid-esp;
    }
cout<<setprecision(4)<<fixed<<kq;
}
/*
5
1.5 2.5
2.5 1.5
1.8 2.2
1.6 2.1
2.5 1.4

*/

Compilation message

sure.cpp: In function 'bool kt(double)':
sure.cpp:19:16: warning: unused variable 'vt' [-Wunused-variable]
   19 |     ll l=1,r=n,vt;
      |                ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2504 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2504 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2504 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 158 ms 2788 KB Output is correct
18 Correct 172 ms 2652 KB Output is correct
19 Correct 144 ms 2680 KB Output is correct
20 Correct 134 ms 2684 KB Output is correct
21 Correct 57 ms 2728 KB Output is correct
22 Correct 148 ms 2648 KB Output is correct
23 Correct 169 ms 2688 KB Output is correct
24 Correct 143 ms 2648 KB Output is correct
25 Correct 140 ms 2684 KB Output is correct
26 Correct 55 ms 2648 KB Output is correct