답안 #687202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
687202 2023-01-26T07:38:03 Z nikhil_kumart21 Mobile (BOI12_mobile) C++17
80 / 100
1000 ms 32352 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 d=sqrt(mid*mid-y[i]*y[i]);
        ll l=x[i]-d,r=x[i]+d;
        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:41:12: warning: unused variable 'l' [-Wunused-variable]
   41 |         ll l,r;
      |            ^
mobile.cpp:41:14: warning: unused variable 'r' [-Wunused-variable]
   41 |         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 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 468 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 5 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 488 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 5 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 468 KB Output is correct
2 Correct 4 ms 484 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 5 ms 484 KB Output is correct
5 Correct 6 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 2648 KB Output is correct
2 Correct 44 ms 2712 KB Output is correct
3 Correct 25 ms 2004 KB Output is correct
4 Correct 76 ms 2644 KB Output is correct
5 Correct 36 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 2644 KB Output is correct
2 Correct 67 ms 2516 KB Output is correct
3 Correct 78 ms 2772 KB Output is correct
4 Correct 87 ms 2772 KB Output is correct
5 Correct 105 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 3060 KB Output is correct
2 Correct 62 ms 2900 KB Output is correct
3 Correct 63 ms 2944 KB Output is correct
4 Correct 126 ms 3424 KB Output is correct
5 Correct 68 ms 3096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 3444 KB Output is correct
2 Correct 80 ms 3444 KB Output is correct
3 Correct 65 ms 3412 KB Output is correct
4 Correct 130 ms 3440 KB Output is correct
5 Correct 108 ms 3440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 3440 KB Output is correct
2 Correct 64 ms 3412 KB Output is correct
3 Correct 55 ms 3440 KB Output is correct
4 Correct 142 ms 3440 KB Output is correct
5 Correct 98 ms 3440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 319 ms 15968 KB Output is correct
2 Correct 345 ms 15968 KB Output is correct
3 Correct 367 ms 15964 KB Output is correct
4 Correct 682 ms 15964 KB Output is correct
5 Correct 595 ms 15964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 434 ms 15968 KB Output is correct
2 Correct 361 ms 15964 KB Output is correct
3 Correct 302 ms 15956 KB Output is correct
4 Correct 663 ms 15968 KB Output is correct
5 Correct 535 ms 15956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 549 ms 19100 KB Output is correct
2 Correct 377 ms 19096 KB Output is correct
3 Correct 344 ms 19104 KB Output is correct
4 Correct 979 ms 19092 KB Output is correct
5 Correct 664 ms 27072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 485 ms 19100 KB Output is correct
2 Correct 455 ms 19092 KB Output is correct
3 Correct 322 ms 19092 KB Output is correct
4 Correct 803 ms 19100 KB Output is correct
5 Correct 603 ms 27808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 480 ms 22228 KB Output is correct
2 Correct 430 ms 22228 KB Output is correct
3 Correct 403 ms 22228 KB Output is correct
4 Correct 916 ms 22240 KB Output is correct
5 Correct 629 ms 31172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 471 ms 22232 KB Output is correct
2 Correct 500 ms 22228 KB Output is correct
3 Correct 412 ms 22228 KB Output is correct
4 Correct 863 ms 22228 KB Output is correct
5 Correct 708 ms 32352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 657 ms 25360 KB Output is correct
2 Correct 496 ms 25356 KB Output is correct
3 Correct 493 ms 25360 KB Output is correct
4 Execution timed out 1077 ms 25356 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 606 ms 25356 KB Output is correct
2 Correct 572 ms 25360 KB Output is correct
3 Correct 401 ms 25300 KB Output is correct
4 Execution timed out 1048 ms 25356 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 762 ms 31624 KB Output is correct
2 Correct 587 ms 31620 KB Output is correct
3 Correct 622 ms 31620 KB Output is correct
4 Execution timed out 1079 ms 31572 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 731 ms 31624 KB Output is correct
2 Correct 704 ms 31620 KB Output is correct
3 Correct 530 ms 31624 KB Output is correct
4 Execution timed out 1072 ms 31572 KB Time limit exceeded
5 Halted 0 ms 0 KB -