답안 #687196

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
687196 2023-01-26T07:34:56 Z nikhil_kumart21 Mobile (BOI12_mobile) C++17
60 / 100
1000 ms 31628 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<=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);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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
# 결과 실행 시간 메모리 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 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 468 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 7 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 7 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 592 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 8 ms 468 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 2644 KB Output is correct
2 Correct 50 ms 2644 KB Output is correct
3 Correct 32 ms 1988 KB Output is correct
4 Correct 106 ms 2660 KB Output is correct
5 Correct 40 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 2772 KB Output is correct
2 Correct 81 ms 2516 KB Output is correct
3 Correct 109 ms 2848 KB Output is correct
4 Correct 116 ms 2784 KB Output is correct
5 Correct 136 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 3068 KB Output is correct
2 Correct 61 ms 2772 KB Output is correct
3 Correct 45 ms 2900 KB Output is correct
4 Correct 180 ms 3420 KB Output is correct
5 Correct 93 ms 3092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 3440 KB Output is correct
2 Correct 59 ms 3440 KB Output is correct
3 Correct 52 ms 3412 KB Output is correct
4 Correct 175 ms 3412 KB Output is correct
5 Correct 125 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 3444 KB Output is correct
2 Correct 61 ms 3444 KB Output is correct
3 Correct 54 ms 3440 KB Output is correct
4 Correct 189 ms 3444 KB Output is correct
5 Correct 129 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 323 ms 15968 KB Output is correct
2 Correct 311 ms 15956 KB Output is correct
3 Correct 276 ms 15960 KB Output is correct
4 Correct 894 ms 15968 KB Output is correct
5 Correct 669 ms 15964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 345 ms 15964 KB Output is correct
2 Correct 392 ms 15956 KB Output is correct
3 Correct 261 ms 15964 KB Output is correct
4 Correct 859 ms 15968 KB Output is correct
5 Correct 714 ms 15968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 396 ms 19100 KB Output is correct
2 Correct 353 ms 19108 KB Output is correct
3 Correct 352 ms 19092 KB Output is correct
4 Execution timed out 1092 ms 19028 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 410 ms 19112 KB Output is correct
2 Correct 425 ms 19096 KB Output is correct
3 Correct 317 ms 19096 KB Output is correct
4 Execution timed out 1085 ms 19048 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 479 ms 22228 KB Output is correct
2 Correct 477 ms 22232 KB Output is correct
3 Correct 398 ms 22348 KB Output is correct
4 Execution timed out 1085 ms 22228 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 496 ms 22228 KB Output is correct
2 Correct 531 ms 22228 KB Output is correct
3 Correct 406 ms 22232 KB Output is correct
4 Execution timed out 1078 ms 22132 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 688 ms 25364 KB Output is correct
2 Correct 495 ms 25364 KB Output is correct
3 Correct 504 ms 25356 KB Output is correct
4 Execution timed out 1084 ms 25288 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 574 ms 25360 KB Output is correct
2 Correct 609 ms 25360 KB Output is correct
3 Correct 443 ms 25356 KB Output is correct
4 Execution timed out 1085 ms 25300 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 735 ms 31628 KB Output is correct
2 Correct 633 ms 31572 KB Output is correct
3 Correct 646 ms 31624 KB Output is correct
4 Execution timed out 1096 ms 31572 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 716 ms 31624 KB Output is correct
2 Correct 788 ms 31624 KB Output is correct
3 Correct 604 ms 31616 KB Output is correct
4 Execution timed out 1047 ms 31620 KB Time limit exceeded
5 Halted 0 ms 0 KB -