Submission #604051

#TimeUsernameProblemLanguageResultExecution timeMemory
604051chuangsheepBalloons (CEOI11_bal)C++11
100 / 100
218 ms8612 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) #define allr(x, r) begin(x), begin(x) + (r) using ll = long long; using ld = long double; ld calc_r(pair<ld, ld> a, ld bx) { return (a.first - bx) * (a.first - bx) / (4 * a.second); } int main() { #if defined(DEBUG) && !defined(ONLINE_JUDGE) // DEBUG cerr << "DEBUG flag set - see test.out for output\n"; freopen("/home/chuang/shared-drives/G:/repos/cp/ois/ceoi11/balloons/test.in", "r", stdin); freopen("/home/chuang/shared-drives/G:/repos/cp/ois/ceoi11/balloons/test.out", "w", stdout); #else cin.tie(0)->sync_with_stdio(false); #endif int n; cin >> n; vector<ld> res(n); stack<pair<ld, ld>> to_check; for (int i = 0; i < n; i++) { ld x, r; cin >> x >> r; ld max_r = r; while (!to_check.empty()) { pair<ld, ld> last = to_check.top(); ld to_last_r = calc_r(last, x); max_r = min(max_r, to_last_r); if (max_r >= last.second) { to_check.pop(); continue; } else { break; } } to_check.push({x,max_r}); res[i] = max_r; } cout << fixed << setprecision(3); for (auto &r : res) { cout << r << "\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...