Submission #1027289

# Submission time Handle Problem Language Result Execution time Memory
1027289 2024-07-19T03:17:22 Z hehebjp123 Sure Bet (CEOI17_sure) C++14
0 / 100
2000 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=1e5+5;
const long long mod=1e9+7;
const double esp=1e-18;
double a[N],b[N];
ll vta,vtb,i,j,n;
bool kt(double k)
{
    for(ll i=1;i<=vta;i++)
    if(a[i]>=k)
    {
    ll l=1,r=vtb,vt;
    if(b[vtb]-(double)i<k) continue;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(b[mid]-(double)i>=k)
        {
            vt=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    if(a[i]-(double)vt>=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>());
    vta=(a[1]>1?1:0);
    vtb=(b[1]>1?1:0);
    a[1]-=1;
    b[1]-=1;
    for(i=2;i<=n;i++)
    {
        if(a[i]>1) vta=i;
        a[i]+=a[i-1]-1;
        if(b[i]>1) vtb=i;
        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;
}
/*
min(a[x]-x-y,b[y]-x-y)
*/

Compilation message

sure.cpp: In function 'bool kt(long double)':
sure.cpp:32:13: warning: 'vt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |     if(a[i]-(double)vt>=k) return 1;
      |             ^~~~~~~~~~
sure.cpp: In function 'int main()':
sure.cpp:32:13: warning: 'vt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |     if(a[i]-(double)vt>=k) return 1;
      |             ^~~~~~~~~~
sure.cpp:20:18: note: 'vt' was declared here
   20 |     ll l=1,r=vtb,vt;
      |                  ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Execution timed out 2100 ms 2396 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Execution timed out 2100 ms 2396 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Execution timed out 2100 ms 2396 KB Time limit exceeded
6 Halted 0 ms 0 KB -