Submission #687192

#TimeUsernameProblemLanguageResultExecution timeMemory
687192nikhil_kumart21Mobile (BOI12_mobile)C++17
60 / 100
1094 ms50928 KiB
#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 (stderr)

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);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...