제출 #1328756

#제출 시각아이디문제언어결과실행 시간메모리
1328756yonatanlBalloons (CEOI11_bal)C++20
30 / 100
243 ms11272 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <iomanip>

#define rep(i, s, e) for (ll i = s; i < e; i++)
#define upmax(a, b) a = max(a, b)
#define upmin(a, b) a = min(a, b)

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;

void solve() {
	ll n;
	cin >> n;
	vector<pair<long double, long double>> arr(n); // { x[i], r[i] }
	rep(i, 0, n) {
		cin >> arr[i].first >> arr[i].second;
	}
	stack<pair<long double, long double>> s;
	s.push({ arr[0].first, arr[0].second});
	vector<long double> ans(n);
	ans[0] = arr[0].second;
	rep(i, 1, n) {
		long double x2 = arr[i].first;
		long double r = arr[i].second;
		while (!s.empty()) {
			long double x1 = s.top().first;
			long double r1 = s.top().second;
			long double curR = ((x2 - x1) * (x2 - x1)) / ((long double)4 * r1);
			upmin(r, curR);
			if (curR >= r1) {
				s.pop();
			}
			else {
				break;
			}
		}
		s.push({ x2, r });
		ans[i] = r;
		/*while (!s.empty()) {
			double x1 = s.top().first;
			double r1 = s.top().second;
			if (r1 < r)
		}*/
	}
	rep(i, 0, n) {
		cout << fixed << setprecision(3) << ans[i] << endl;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	ll t = 1;
	while (t--) {
		solve();
	}
}
#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...