Submission #401572

# Submission time Handle Problem Language Result Execution time Memory
401572 2021-05-10T13:38:19 Z benk Balloons (CEOI11_bal) C++14
100 / 100
196 ms 8404 KB
#include "bits/stdc++.h"
using namespace std;

#define all(x)      x.begin(), x.end()
#define pb          push_back
#define sz(x)       (int)(x.size())
#define ll          long long
#define fi          first
#define se          second
#define lbd         lower_bound
#define ubd         upper_bound

const int MOD = 1e9 + 7;
const double eps = 1e-10;
const long long INF = 1e18;
const int N = 2e5 + 10;


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

	stack<pair<int, double>> s;
	for (int i = 0; i < n; i++) {
		ll tmp;
		double r1 = r[i];
		while (!s.empty()) {
			tmp = 1LL * (x[i] - s.top().fi) * (x[i] - s.top().fi);
			r1 = min(1.0 * r1, tmp / (4 * s.top().se));
			if (r1 >= s.top().se) s.pop();
			else break;
		}

		cout << fixed << setprecision(10) << r1 << '\n';
		s.push({x[i], r1});
	}
}

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

	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 336 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 21 ms 804 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 62 ms 1796 KB 50000 numbers
2 Correct 54 ms 2240 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 112 ms 2860 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 123 ms 3272 KB 115362 numbers
2 Correct 115 ms 5148 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 159 ms 4104 KB 154271 numbers
2 Correct 163 ms 8396 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 196 ms 4984 KB 200000 numbers
2 Correct 179 ms 8404 KB 199945 numbers