Submission #551197

#TimeUsernameProblemLanguageResultExecution timeMemory
551197narcissusMobile (BOI12_mobile)C++17
0 / 100
775 ms24600 KiB
#include <iostream> #include <algorithm> #include <cmath> using namespace std; int main() { int n, l; cin >> n >> l; pair<int, int> coords[n]; for (int i = 0; i < n; i++) { cin >> coords[i].first >> coords[i].second; } double low = 0, high = l; while (high - low >= 1e-3) { double mid = low + (high - low) / 2; // cout << mid << ":" << endl; bool flag = true; pair<double, double> inter, prevInter; double minv = l, maxv = 0; for (int i = 0; i < n; i++) { int x = coords[i].first; int y = coords[i].second; double xdist = sqrt(pow(mid, 2) - pow(y, 2)); double a1 = max((double)0, -xdist + x); double a2 = min((double)l, xdist + x); minv = min(minv, a1); maxv = max(maxv, a2); // cout << "a " << a1 << ' ' << a2 << endl; inter = {a1, a2}; if (i) { if (a1 > prevInter.second) { flag = false; break; } } prevInter = inter; } if (flag && minv <= 0 && maxv >= l) { high = mid; } else { low = mid; } } cout << high << endl; 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...