Submission #1299785

#TimeUsernameProblemLanguageResultExecution timeMemory
1299785polishprogrammerBalloons (CEOI11_bal)C++20
40 / 100
615 ms4416 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define lld long double #define fi first #define se second #define pb push_back lld odl(pair<lld, lld> p1, pair<lld, lld> p2) { return sqrt((p1.fi-p2.fi)*(p1.fi-p2.fi) + (p1.se-p2.se)*(p1.se-p2.se)); } bool czy(lld xs, lld rs, lld x, lld r) { if (odl({xs, rs}, {x, r}) >= rs + r) return 1; return 0; } lld promien(pair<lld, lld> okr, pair<lld, lld> nowy) { lld xs = okr.fi, rs = okr.se, x = nowy.fi, r = nowy.se, pocz = 0, kon = r, sr; //cout << xs << " " << rs << " " << x << " " << r << endl; while (kon - pocz > 1.0/1e5) { sr = (pocz + kon) / 2; //cout << pocz << " " << sr << " " << kon << " " << czy(xs, rs, x, sr) << endl; if (czy(xs, rs, x, sr)) pocz = sr; else kon = sr; } return pocz; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); lld n, r, x; cin >> n; vector<pair<lld, lld>> okr; for (lld i = 0; i < n; i++) { cin >> x >> r; lld wyn = r; while (!okr.empty() and promien(okr.back(), {x, r}) >= okr.back().se) { wyn = min(wyn, promien(okr.back(), {x, r})); okr.pop_back(); } if (!okr.empty()) wyn = min(wyn, promien(okr.back(), {x, r})); cout << fixed << setprecision(3) << wyn << endl; okr.pb({x, wyn}); } }
#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...