Submission #687201

# Submission time Handle Problem Language Result Execution time Memory
687201 2023-01-26T07:36:31 Z nikhil_kumart21 Mobile (BOI12_mobile) C++17
60 / 100
1000 ms 31624 KB

#include <bits/stdc++.h>

using namespace std;

typedef long double  ll;
#define endl "\n";

void setIO(string s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}
ll fun(ll x[],ll y[],int n,ll mid,ll L){
    // cout<<mid<<endl;
    ll num=0;
    for(int i=0;i<n;++i){
        if(mid<y[i])continue;
        ll l=x[i]-sqrt(mid*mid-y[i]*y[i]),r=x[i]+sqrt(mid*mid-y[i]*y[i]);
        if(l<=num){
            num=max(num,r);
        }
        if(num>=L)return 0;
        // cout<<l<<" "<<r<<endl;
    }
    return num<L;
    
}
int main()
{
    // setIO("angry");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    int n;
    ll L;
    cin>>n>>L;
    ll x[n],y[n];
    for(int i=0;i<n;++i){
        ll l,r;
        cin>>x[i]>>y[i];
    }
    
    // sort(v.begin(),v.end(),comp);
    ll l=0,r=2e9,mid,ans=0;
    while(l+1e-4<r){
        mid=l+(r-l)/2;
        if(fun(x,y,n,mid,L)){
            l=mid+1e-4;
            ans=mid;
        }
        else{
            r=mid-1e-4;
        }
    }
    cout<<fixed<<setprecision(3)<<ans<<endl;
    
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:40:12: warning: unused variable 'l' [-Wunused-variable]
   40 |         ll l,r;
      |            ^
mobile.cpp:40:14: warning: unused variable 'r' [-Wunused-variable]
   40 |         ll l,r;
      |              ^
mobile.cpp: In function 'void setIO(std::string)':
mobile.cpp:11:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  freopen((s + ".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:12:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  freopen((s + ".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 484 KB Output is correct
2 Correct 5 ms 484 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 9 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 7 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 9 ms 468 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 2660 KB Output is correct
2 Correct 45 ms 2644 KB Output is correct
3 Correct 27 ms 2004 KB Output is correct
4 Correct 115 ms 2644 KB Output is correct
5 Correct 43 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 2772 KB Output is correct
2 Correct 78 ms 2516 KB Output is correct
3 Correct 101 ms 2852 KB Output is correct
4 Correct 108 ms 2772 KB Output is correct
5 Correct 134 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 3068 KB Output is correct
2 Correct 56 ms 2900 KB Output is correct
3 Correct 40 ms 2900 KB Output is correct
4 Correct 166 ms 3424 KB Output is correct
5 Correct 92 ms 3100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 3444 KB Output is correct
2 Correct 65 ms 3452 KB Output is correct
3 Correct 51 ms 3412 KB Output is correct
4 Correct 168 ms 3412 KB Output is correct
5 Correct 120 ms 3444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 3440 KB Output is correct
2 Correct 65 ms 3440 KB Output is correct
3 Correct 62 ms 3444 KB Output is correct
4 Correct 173 ms 3440 KB Output is correct
5 Correct 124 ms 3440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 318 ms 15968 KB Output is correct
2 Correct 315 ms 15964 KB Output is correct
3 Correct 279 ms 15964 KB Output is correct
4 Correct 829 ms 15968 KB Output is correct
5 Correct 628 ms 15960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 350 ms 15968 KB Output is correct
2 Correct 337 ms 15968 KB Output is correct
3 Correct 248 ms 15964 KB Output is correct
4 Correct 841 ms 15964 KB Output is correct
5 Correct 675 ms 15976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 420 ms 19096 KB Output is correct
2 Correct 354 ms 19096 KB Output is correct
3 Correct 321 ms 19096 KB Output is correct
4 Execution timed out 1082 ms 19028 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 398 ms 19092 KB Output is correct
2 Correct 397 ms 19092 KB Output is correct
3 Correct 318 ms 19116 KB Output is correct
4 Execution timed out 1016 ms 19100 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 457 ms 22228 KB Output is correct
2 Correct 430 ms 22228 KB Output is correct
3 Correct 400 ms 22228 KB Output is correct
4 Execution timed out 1097 ms 22180 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 453 ms 22228 KB Output is correct
2 Correct 452 ms 22236 KB Output is correct
3 Correct 358 ms 22224 KB Output is correct
4 Execution timed out 1094 ms 22228 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 501 ms 25360 KB Output is correct
2 Correct 454 ms 25360 KB Output is correct
3 Correct 431 ms 25368 KB Output is correct
4 Execution timed out 1089 ms 25300 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 530 ms 25356 KB Output is correct
2 Correct 511 ms 25360 KB Output is correct
3 Correct 377 ms 25300 KB Output is correct
4 Execution timed out 1094 ms 25300 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 621 ms 31624 KB Output is correct
2 Correct 582 ms 31624 KB Output is correct
3 Correct 590 ms 31620 KB Output is correct
4 Execution timed out 1087 ms 31592 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 652 ms 31616 KB Output is correct
2 Correct 638 ms 31624 KB Output is correct
3 Correct 513 ms 31616 KB Output is correct
4 Execution timed out 1090 ms 31572 KB Time limit exceeded
5 Halted 0 ms 0 KB -