Submission #698059

#TimeUsernameProblemLanguageResultExecution timeMemory
698059caganyanmazMobile (BOI12_mobile)C++14
0 / 100
1096 ms78528 KiB
#include <bits/stdc++.h> #define int int64_t #define f first #define s second #define mp make_pair using namespace std; bool check(int r, int L, const vector<array<int, 2>>& stations) { set<pair<int, int>> intervals; for (const array<int, 2>& station : stations) { int diff_sqrd = r * r - station[1] * station[1]; if (diff_sqrd < 0) continue; int diff = sqrt(diff_sqrd); int _l = station[0] - diff, _r = station[0] + diff; if (_l > L || _r < 0) continue; intervals.insert(mp(_l, _r)); } if (intervals.begin()->f > 0) return false; int last = (*intervals.begin()).s; for (auto it = intervals.begin(); it != intervals.end() && last < L && it->f <= last; it++) { last = max(last, it->s); } return last >= L; } int32_t main() { int N, L; cin >> N >> L; vector<array<int, 2>> stations(N); for (int i = 0; i < N; i++) { for (int j = 0; j < 2; j++) { cin >> stations[i][j]; stations[i][j] *= 1e4; } } L *= 1e4; int l = 0, r = 4e13; while (r - l > 1) { int m = l+r>>1; if (check(m, L, stations)) r = m; else l = m; } cout << (static_cast<double>(r) / 1e4) << "\n"; }

Compilation message (stderr)

mobile.cpp: In function 'int32_t main()':
mobile.cpp:51:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |         int m = l+r>>1;
      |                 ~^~
#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...