Submission #748637

# Submission time Handle Problem Language Result Execution time Memory
748637 2023-05-26T16:26:38 Z TAhmed33 Balloons (CEOI11_bal) C++
100 / 100
363 ms 16020 KB
#include <bits/stdc++.h>
using namespace std;
#define ld long double
ld calc (pair <ld, ld> x, ld a) {
	return (a - x.first) * (a - x.first) / (4 * x.second);
}
int main () {
	cout << fixed << setprecision(9);
	int n;
	cin >> n;
	ld arr[n][2] = {};
	for (int i = 0; i < n; i++) cin >> arr[i][0] >> arr[i][1];
	stack <pair <ld, ld>> cur;
	ld ans[n];
	ans[0] = arr[0][1];
	cur.push({arr[0][0], ans[0]});
	for (int i = 1; i < n; i++) {
		ans[i] = arr[i][1];
		while (!cur.empty()) {
			auto k = cur.top();
			ans[i] = min(ans[i], calc(k, arr[i][0]));
			if (k.second <= ans[i]) cur.pop();
			else break;
		}
		cur.push({arr[i][0], ans[i]});
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << " ";
	}
	cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1680 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 89 ms 4360 KB 50000 numbers
2 Correct 83 ms 4152 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 167 ms 8140 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 196 ms 9384 KB 115362 numbers
2 Correct 198 ms 9664 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 286 ms 12212 KB 154271 numbers
2 Correct 342 ms 16020 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 363 ms 15288 KB 200000 numbers
2 Correct 325 ms 15944 KB 199945 numbers