Submission #1064682

#TimeUsernameProblemLanguageResultExecution timeMemory
1064682davieduMobile (BOI12_mobile)C++17
100 / 100
379 ms41808 KiB
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(0); cin.tie(0) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ll long long #define ld long double struct P{ ll x, y; }; void dbg_out() { cerr << endl; } template <typename H, typename... T> void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); } #define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); } ld border(ld x, ld y, ld a, ld b){ return (a*a + b*b - x*x - y*y) / (2*a - 2*x); } ld dist(ld x, ld y, ld point){ return sqrtl(y*y + (point-x)*(point-x)); } signed main(){ fastio; int n, r; cin >> n >> r; stack<pair<ld, ld>> st; // this will be useful for simplifying implementation later st.push({-2e9, -2e9}); ld a, b, x, y; for (int i=0; i<n; i++){ cin >> a >> b; if (b < 0) b = -b; while (!st.empty() && st.top().first == a && st.top().second > b) st.pop(); while ((int)st.size() > 1){ tie(x, y) = st.top(); st.pop(); // if prev is not a useless point, put it back and stop if (border(x, y, a, b) > border(st.top().first, st.top().second, x, y)){ st.push({x, y}); break; } } st.push({a, b}); } ld ans=0; ld right=r; while ((int)st.size() > 1){ tie(a, b) = st.top(); st.pop(); tie(x, y) = st.top(); ld left = border(x, y, a, b); // not in some interesting range yet if (left >= right) continue; ans = max(ans, dist(a, b, right)); ans = max(ans, dist(a, b, max(left, (ld)0))); // from here onwards we will be looking at non interesting ranges if (left <= 0) break; right = left; } cout << fixed << setprecision(13); cout << ans << '\n'; }
#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...