Submission #405684

#TimeUsernameProblemLanguageResultExecution timeMemory
405684huukhangBalloons (CEOI11_bal)C++11
100 / 100
253 ms10156 KiB
/*
						   Khangnh's code

“You can either experience the pain of discipline or the pain of regret. 
						The choice is yours.”
*/

// - Only when necessary :d
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

#define fileopen(a, b) freopen(((string)a + ".inp").c_str(), "r", stdin); freopen(((string)b + ".out").c_str(), "w", stdout); 

#define ll long long
#define ld long double
#define int long long
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
typedef pair<int, int> pii;

const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const double eps = 1e-9;

int n;
int x[200005];
ld r[200005];
stack<pair<int, ld>> st;

ld inflate(int x0, ld r0) {
	while (!st.empty()) {
		pair<int, ld> k = st.top();
		int tmp = (k.fi - x0)*(k.fi - x0);
		r0 = min(r0, tmp/(4*k.se));

		if (r0 >= k.se) st.pop();
		else break;
	}
	st.push({x0, r0});

	return r0;
}

void solve() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> x[i] >> r[i];

	cout << fixed << setprecision(3);
	for (int i = 1; i <= n; ++i) cout << inflate(x[i], r[i]) << "\n";
}

signed main() {
	#ifdef LOCAL
		fileopen("input", "output");
		auto start = clock();
	#endif
	#ifndef LOCAL
//		fileopen("LAH", "LAH");
	#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
//	cin >> t;
	while (t--) solve();
	#ifdef LOCAL
		auto end = clock();
		cout << "\n\nExecution time : " << double(end - start)/CLOCKS_PER_SEC << "[s]";
	#endif
	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...