답안 #687213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
687213 2023-01-26T07:44:26 Z nikhil_kumart21 Mobile (BOI12_mobile) C++17
100 / 100
865 ms 22872 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);
}
int x[1000001],y[1000001];
int n;
ll fun(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]*1ll*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);
    
    ll L;
    cin>>n>>L;
    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(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 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 340 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 2 ms 340 KB Output is correct
4 Correct 4 ms 340 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 1 ms 340 KB Output is correct
4 Correct 5 ms 340 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 1 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 936 KB Output is correct
2 Correct 25 ms 948 KB Output is correct
3 Correct 16 ms 724 KB Output is correct
4 Correct 58 ms 904 KB Output is correct
5 Correct 15 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 952 KB Output is correct
2 Correct 47 ms 884 KB Output is correct
3 Correct 49 ms 972 KB Output is correct
4 Correct 56 ms 948 KB Output is correct
5 Correct 69 ms 1000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1020 KB Output is correct
2 Correct 24 ms 972 KB Output is correct
3 Correct 17 ms 1012 KB Output is correct
4 Correct 88 ms 1112 KB Output is correct
5 Correct 43 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 1140 KB Output is correct
2 Correct 26 ms 1108 KB Output is correct
3 Correct 23 ms 1008 KB Output is correct
4 Correct 82 ms 1084 KB Output is correct
5 Correct 61 ms 1124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 1108 KB Output is correct
2 Correct 28 ms 1108 KB Output is correct
3 Correct 27 ms 1052 KB Output is correct
4 Correct 95 ms 1016 KB Output is correct
5 Correct 73 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 230 ms 4140 KB Output is correct
2 Correct 131 ms 4244 KB Output is correct
3 Correct 121 ms 4240 KB Output is correct
4 Correct 408 ms 4244 KB Output is correct
5 Correct 309 ms 4248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 186 ms 4212 KB Output is correct
2 Correct 205 ms 4172 KB Output is correct
3 Correct 102 ms 4168 KB Output is correct
4 Correct 414 ms 4244 KB Output is correct
5 Correct 354 ms 4240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 224 ms 5024 KB Output is correct
2 Correct 167 ms 4936 KB Output is correct
3 Correct 130 ms 4952 KB Output is correct
4 Correct 535 ms 5024 KB Output is correct
5 Correct 384 ms 5024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 193 ms 4904 KB Output is correct
2 Correct 239 ms 5020 KB Output is correct
3 Correct 138 ms 5068 KB Output is correct
4 Correct 541 ms 5020 KB Output is correct
5 Correct 433 ms 5004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 244 ms 5800 KB Output is correct
2 Correct 192 ms 5816 KB Output is correct
3 Correct 189 ms 5760 KB Output is correct
4 Correct 599 ms 5800 KB Output is correct
5 Correct 454 ms 5804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 255 ms 5736 KB Output is correct
2 Correct 309 ms 5800 KB Output is correct
3 Correct 157 ms 5796 KB Output is correct
4 Correct 586 ms 5800 KB Output is correct
5 Correct 502 ms 5760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 289 ms 6584 KB Output is correct
2 Correct 200 ms 6684 KB Output is correct
3 Correct 186 ms 6460 KB Output is correct
4 Correct 734 ms 6588 KB Output is correct
5 Correct 500 ms 17732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 242 ms 6604 KB Output is correct
2 Correct 303 ms 6664 KB Output is correct
3 Correct 174 ms 6584 KB Output is correct
4 Correct 672 ms 6600 KB Output is correct
5 Correct 541 ms 18160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 361 ms 8152 KB Output is correct
2 Correct 243 ms 8060 KB Output is correct
3 Correct 267 ms 8016 KB Output is correct
4 Correct 865 ms 8140 KB Output is correct
5 Correct 643 ms 21696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 362 ms 8140 KB Output is correct
2 Correct 358 ms 8140 KB Output is correct
3 Correct 222 ms 8088 KB Output is correct
4 Correct 846 ms 8160 KB Output is correct
5 Correct 710 ms 22872 KB Output is correct