Submission #1004526

#TimeUsernameProblemLanguageResultExecution timeMemory
1004526ThunnusBalloons (CEOI11_bal)C++17
100 / 100
148 ms8764 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; using i64 = long long; template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define int i64 #define vi vector<int> #define vvi vector<vi> #define vb vector<bool> #define pii pair<int, int> #define fi first #define se second #define double long double #define sz(x) (int)(x).size() inline double calc_radius(pair<double, double> a, double bx){ // a.fi -> a.x, a.se -> a.r return (a.fi - bx) * (a.fi - bx) / (4 * a.se); // comes from Pythagorean theorem } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; double x, r; cin >> n; stack<pair<double, double>> s; vector<double> ans(n); for(int i = 0; i < n; i++){ cin >> x >> r; double maxr = r; while(!s.empty()){ pair<double, double> prev = s.top(); double curr = calc_radius(prev, x); maxr = min(maxr, curr); if(maxr >= prev.se) s.pop(); else break; } s.push({x, maxr}); ans[i] = maxr; } cout << fixed << setprecision(3); for(double d : ans) cout << d << "\n"; 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...