Submission #762721

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

double maxRadius(int x1, int x2, double r1) {
	return 1LL * (x2 - x1) * (x2 - x1) / (4 * r1);
}

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

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

	for (int i = 0; i < n; i++) {
		int x2; cin >> x2;
		double r2; cin >> r2;
		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 Correct 0 ms 320 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 328 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 15 ms 692 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 41 ms 1568 KB 50000 numbers
2 Correct 38 ms 1516 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 76 ms 2644 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 85 ms 3128 KB 115362 numbers
2 Correct 84 ms 3388 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 117 ms 4040 KB 154271 numbers
2 Correct 140 ms 5448 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 145 ms 4612 KB 200000 numbers
2 Correct 140 ms 5364 KB 199945 numbers