답안 #687192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
687192 2023-01-26T07:31:15 Z nikhil_kumart21 Mobile (BOI12_mobile) C++17
60 / 100
1000 ms 50928 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]-sqrtl(mid*mid-y[i]*y[i]),r=x[i]+sqrtl(mid*mid-y[i]*y[i]);
        if(l<=num){
            num=max(num,r);
        }
        // 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:39:12: warning: unused variable 'l' [-Wunused-variable]
   39 |         ll l,r;
      |            ^
mobile.cpp:39:14: warning: unused variable 'r' [-Wunused-variable]
   39 |         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 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 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 6 ms 468 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 4 ms 480 KB Output is correct
4 Correct 8 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 488 KB Output is correct
2 Correct 5 ms 488 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 7 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 468 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 5 ms 468 KB Output is correct
4 Correct 11 ms 468 KB Output is correct
5 Correct 7 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 2648 KB Output is correct
2 Correct 55 ms 2644 KB Output is correct
3 Correct 34 ms 1876 KB Output is correct
4 Correct 122 ms 2644 KB Output is correct
5 Correct 56 ms 1888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 2772 KB Output is correct
2 Correct 99 ms 2516 KB Output is correct
3 Correct 114 ms 2772 KB Output is correct
4 Correct 119 ms 2772 KB Output is correct
5 Correct 142 ms 3028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 3028 KB Output is correct
2 Correct 74 ms 2900 KB Output is correct
3 Correct 69 ms 2952 KB Output is correct
4 Correct 178 ms 5364 KB Output is correct
5 Correct 114 ms 4020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 3440 KB Output is correct
2 Correct 73 ms 3440 KB Output is correct
3 Correct 69 ms 4476 KB Output is correct
4 Correct 181 ms 5476 KB Output is correct
5 Correct 156 ms 4572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 3412 KB Output is correct
2 Correct 71 ms 3444 KB Output is correct
3 Correct 64 ms 4472 KB Output is correct
4 Correct 176 ms 5324 KB Output is correct
5 Correct 140 ms 4592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 353 ms 15968 KB Output is correct
2 Correct 432 ms 23620 KB Output is correct
3 Correct 373 ms 23184 KB Output is correct
4 Correct 887 ms 25520 KB Output is correct
5 Correct 727 ms 22784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 390 ms 15964 KB Output is correct
2 Correct 381 ms 22584 KB Output is correct
3 Correct 329 ms 21708 KB Output is correct
4 Correct 871 ms 25288 KB Output is correct
5 Correct 748 ms 23256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 19096 KB Output is correct
2 Correct 468 ms 28304 KB Output is correct
3 Correct 492 ms 27784 KB Output is correct
4 Execution timed out 1075 ms 30856 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 495 ms 19028 KB Output is correct
2 Correct 461 ms 27032 KB Output is correct
3 Correct 405 ms 25936 KB Output is correct
4 Execution timed out 1075 ms 30724 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 509 ms 22228 KB Output is correct
2 Correct 553 ms 32964 KB Output is correct
3 Correct 528 ms 32368 KB Output is correct
4 Execution timed out 1094 ms 35644 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 565 ms 22228 KB Output is correct
2 Correct 547 ms 31432 KB Output is correct
3 Correct 468 ms 30604 KB Output is correct
4 Execution timed out 1079 ms 35520 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 541 ms 25360 KB Output is correct
2 Correct 607 ms 37748 KB Output is correct
3 Correct 624 ms 36860 KB Output is correct
4 Execution timed out 1063 ms 40964 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 577 ms 25360 KB Output is correct
2 Correct 618 ms 35936 KB Output is correct
3 Correct 535 ms 34936 KB Output is correct
4 Execution timed out 1024 ms 40708 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 745 ms 31616 KB Output is correct
2 Correct 900 ms 47144 KB Output is correct
3 Correct 844 ms 46156 KB Output is correct
4 Execution timed out 1066 ms 50680 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 866 ms 31624 KB Output is correct
2 Correct 829 ms 44792 KB Output is correct
3 Correct 961 ms 43888 KB Output is correct
4 Execution timed out 1091 ms 50928 KB Time limit exceeded
5 Halted 0 ms 0 KB -