Submission #995176

#TimeUsernameProblemLanguageResultExecution timeMemory
995176VMaksimoski008Mobile (BOI12_mobile)C++17
0 / 100
1074 ms41128 KiB
#include <bits/stdc++.h> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; const double eps = 1e-9; int32_t main() { int n, L; cin >> n >> L; vector<int> x(n), y(n); for(int i=0; i<n; i++) cin >> x[i] >> y[i]; double l=0.000001, r=10, ans=r; // double l = 5.545455, r=10, ans=r; for(int it=0; it<100; it++) { double mid = (l + r) / 2.0; vector<pdd> seg; //cout << mid << '\n'; for(int i=0; i<n; i++) { double len = sqrt(mid * mid - y[i] * y[i]); seg.push_back({ max((double)0, x[i] - len), min((double)L, x[i] + len) }); //cout << seg.back().first << " " << seg.back().second << '\n'; } sort(seg.begin(), seg.end()); bool ok = 1; double lp=seg[0].first, rp=seg[0].second; if(lp > 0) ok = 0; for(int i=1; i<n; i++) { if(seg[i].first > rp) ok = 0; rp = max(rp, seg[i].second); } if(ok && rp >= L) ans = r = mid; else l = mid; } cout << setprecision(8) << fixed << ans << '\n'; return 0; }
#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...