Submission #989981

#TimeUsernameProblemLanguageResultExecution timeMemory
989981maithehung123Mobile (BOI12_mobile)C++14
100 / 100
902 ms35436 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define BIT(i) (1LL << (i)) #define GBIT(mask,i) (((mask) >> (i)) & 1) #define ALL(v) v.begin(),v.end() #define pb push_back #define sz(v) ((int)v.size()) #define FOR(i,a,b) for(int i = a; i <= b; ++i) #define FOD(i,a,b) for(int i = a; i >= b; --i) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const int inf = 2e9 + 7; const long long infll = 1e18 + 7; template<class T1,class T2> bool maximize(T1 &a,T2 b) { if(a < b) { a = b; return 1; } return 0; } template<class T1,class T2> bool minimize(T1 &a,T2 b) { if(a > b) { a = b; return 1; } return 0; } #define MAX 1000005 int n; int L; pll a[MAX]; bool check(long double x) { long double cur = 0.0; FOR(i,1,n) { long double delta = sqrt(x * x - 1.0 * a[i].se * a[i].se); long double left = a[i].fi - delta,right = a[i].fi + delta; if(left <= cur) maximize(cur,right); } return cur >= L; } void process() { cin >> n >> L; FOR(i,1,n) cin >> a[i].fi >> a[i].se; long double l = 0,r = 1e9 + 7,mid,res; while(r - l >= 1e-5) { mid = (l + r) / 2; if(check(mid)) r = mid,res = mid; else l = mid; } cout << fixed << setprecision(6) << res; } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define TASK "" if(fopen(TASK".inp","r")) { freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout); } if(fopen("main.inp","r")) { freopen("main.inp","r",stdin); freopen("main.out","w",stdout); } srand(time(0)); process(); cerr << "\n" << (double)clock() / CLOCKS_PER_SEC * 1000 << "ms"; return 0; }

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen(TASK".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:72:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         freopen(TASK".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:76:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         freopen("main.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen("main.out","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...