Submission #1027322

# Submission time Handle Problem Language Result Execution time Memory
1027322 2024-07-19T03:42:04 Z hehebjp123 Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 2396 KB
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,O3,unroll-loops")
#define double long double
#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;
    double tmp=i;
    if(b[n]-tmp<k) continue;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(b[mid]-tmp>=k)
        {
            vt=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    tmp=vt;
    if(a[i]-tmp>=k) return 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;
    ll l=0,r=1e12;
    double kq;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        double tmp=mid;
        tmp/=10000;
       cout<<l<<" "<<r<<" "<<mid<<'\n';
        if(kt(tmp))
        {
            kq=tmp;
            l=mid+1;
        }
        else r=mid-1;
    }
cout<<setprecision(4)<<fixed<<kq;
}
/*
5
1.5 2.5
2.5 1.8
1.8 2.2
1.6 2.1
2.5 1.4

*/

Compilation message

sure.cpp: In function 'bool kt(long double)':
sure.cpp:33:8: warning: 'vt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |     tmp=vt;
      |     ~~~^~~
sure.cpp: In function 'int main()':
sure.cpp:33:8: warning: 'vt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |     tmp=vt;
      |     ~~~^~~
sure.cpp:20:16: note: 'vt' was declared here
   20 |     ll l=1,r=n,vt;
      |                ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -