Submission #762061

# Submission time Handle Problem Language Result Execution time Memory
762061 2023-06-20T17:21:06 Z Sig0001 Balloons (CEOI11_bal) C++17
20 / 100
171 ms 11272 KB
#include <bits/stdc++.h>
using namespace std;

double maxRadius(int x1, int x2, double r1) {
	/**
	 * (x2 - x1)^2 + (r2 - r1)^2 = (r2 + r1)^2
	 * (x2 - x1)^2 = 4 r1 r2
	 */
	return (x2 - x1) * (x2 - x1) / (4 * r1);
}

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

	int n; cin >> n;
	vector<pair<int, double>> a(n);  // [x, maxRadius]
	for (auto &[x, r]: a) cin >> x >> r;

	vector<double> ans(n);
	ans[0] = a[0].second;

	stack<pair<int, double>> st;  // [position, radius]
	cout << fixed << setprecision(3);

	for (int i = 0; i < n; i++) {
		auto [x2, maxR2] = a[i];
		double r2 = maxR2;
		while (not st.empty()) {
			auto [x1, r1] = st.top();
			r2 = min(r2, maxRadius(x1, x2, r1));
			if (r2 < r1) break;
			st.pop();
		}
		st.emplace(x2, r2);
		cout << r2 << '\n';
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB 2nd numbers differ - expected: '252735385.4379999936', found: '0.9330000000', error = '252735384.5049999952'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 372 KB 506th numbers differ - expected: '365.0000000000', found: '-2481854.0649999999', error = '2482219.0649999999'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 1412 KB 655th numbers differ - expected: '591.0000000000', found: '-2402336.3029999998', error = '2402927.3029999998'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 2788 KB 4th numbers differ - expected: '15396.0000000000', found: '-8148.5510000000', error = '23544.5510000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 5648 KB 7234th numbers differ - expected: '7160.0000000000', found: '-2398141.9989999998', error = '2405301.9989999998'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 94 ms 6292 KB 4643rd numbers differ - expected: '2427.0000000000', found: '-2355611.7020000000', error = '2358038.7020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 129 ms 8436 KB 1734th numbers differ - expected: '1856.0220000000', found: '-2324667.3859999999', error = '2326523.4079999998'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 171 ms 11272 KB 2723rd numbers differ - expected: '859.0470000000', found: '-2333711.4849999999', error = '2334570.5319999997'
2 Halted 0 ms 0 KB -