Submission #126735

#TimeUsernameProblemLanguageResultExecution timeMemory
126735Mahmoud_AdelMobile (BOI12_mobile)C++14
0 / 100
1077 ms39280 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second typedef long long ll; const int N = 1e6+5, mod = 1e9+7; int n, m; pair<double, double> p[N]; stack<pair<int, pair<double, double>>> s; double dis(int i, double x) { double y = 0; return hypot((x-p[i].f), (y-p[i].s)); } int main() { cin >> n >> m; for(int i=0; i<n; i++) cin >> p[i].f >> p[i].s; for(int i=0; i<n; i++) { if(s.empty()) s.push({i, {0, m}}); else { auto t = s.top(); if(dis(t.f, t.s.f) >= dis(i, t.s.f)) { s.pop(); s.push({i, {t.s.f, t.s.s}}); } else if(dis(t.f, t.s.s) > dis(i, t.s.s)) { double x, x1 = p[i].f, x2 = p[t.f].f; double y1 = p[i].s, y2 = p[t.f].s; x = (x1*x1 - x2*x2 + y1*y1-y2*y2)/(2*x1-2*x2); s.pop(); t.s.s = x; s.push(t), s.push({i, {x, m}}); } } } double ans = 0; while(!s.empty()) { auto t = s.top(); s.pop(); ans = max(ans, max(dis(t.f, t.s.f), dis(t.f, t.s.s))); } cout << fixed << setprecision(4) << ans << endl; }
#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...