답안 #687171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
687171 2023-01-26T07:10:40 Z nikhil_kumart21 Mobile (BOI12_mobile) C++17
35 / 100
1000 ms 131072 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(vector<vector<ll>>&v,ll mid,ll L){
    vector<vector<ll>>a;
    // cout<<mid<<endl;
    for(auto it:v){
        if(mid<it[1])continue;
        ll l=it[0]-sqrtl(mid*mid-it[1]*it[1]),r=it[0]+sqrtl(mid*mid-it[1]*it[1]);
        if(l<=L&&r>=0)
        a.push_back({l,r});

        // cout<<l<<" "<<r<<endl;
    }
    if(a.empty())return 1;
    // cout<<endl;
    // if()
    sort(a.begin(),a.end());
    if(a[0][0]>0)return 1;
    ll num=a[0][1];
    for(int i=1;i<a.size();++i){
        auto it=a[i];
        if(it[0]>num)return 1;
        num=max(num,it[1]);
    }
    if(num<L)return 1;
    return 0;
}
    
int main()
{
    // setIO("angry");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll n,L;
    cin>>n>>L;
    vector<vector<ll>>v;
    for(int i=0;i<n;++i){
        ll l,r;
        cin>>l>>r;
        v.push_back({l,r});
    }
    ll l=0,r=2e9,mid,ans=0;
    while(l<=r){
        mid=l+(r-l)/2;
        if(fun(v,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 'll fun(std::vector<std::vector<long double> >&, ll, ll)':
mobile.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=1;i<a.size();++i){
      |                 ~^~~~~~~~~
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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 16 ms 740 KB Output is correct
2 Correct 23 ms 756 KB Output is correct
3 Correct 12 ms 596 KB Output is correct
4 Correct 13 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1108 KB Output is correct
2 Correct 47 ms 1244 KB Output is correct
3 Correct 49 ms 1136 KB Output is correct
4 Correct 30 ms 1172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1108 KB Output is correct
2 Correct 40 ms 1140 KB Output is correct
3 Correct 44 ms 1108 KB Output is correct
4 Correct 25 ms 1180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1076 KB Output is correct
2 Correct 40 ms 1168 KB Output is correct
3 Correct 53 ms 1124 KB Output is correct
4 Correct 23 ms 1168 KB Output is correct
5 Correct 29 ms 1168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 373 ms 11892 KB Output is correct
2 Correct 889 ms 13388 KB Output is correct
3 Correct 512 ms 8496 KB Output is correct
4 Correct 441 ms 13348 KB Output is correct
5 Correct 331 ms 7780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 528 ms 12440 KB Output is correct
2 Correct 430 ms 12384 KB Output is correct
3 Correct 485 ms 13580 KB Output is correct
4 Correct 411 ms 13704 KB Output is correct
5 Correct 474 ms 14752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 813 ms 13456 KB Output is correct
2 Correct 916 ms 12840 KB Output is correct
3 Execution timed out 1077 ms 14028 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 964 ms 14672 KB Output is correct
2 Execution timed out 1085 ms 16104 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 530 ms 14416 KB Output is correct
2 Execution timed out 1080 ms 14464 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 70760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1052 ms 70784 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1051 ms 93668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1088 ms 93640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1080 ms 105224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 105036 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 113056 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1086 ms 113144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 518 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 623 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -