답안 #974142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974142 2024-05-02T22:47:37 Z AksLolCoding Balloons (CEOI11_bal) C++17
100 / 100
143 ms 5596 KB
#include <bits/stdc++.h>
using namespace std;

using ld = long double;
using ld2 = array<ld, 2>;

ld rad(ld2 prev, ld x) {
	return ((prev[0]-x)*(prev[0]-x)/(4*prev[1]));
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;

	// solve
	stack<ld2> check;
	while (n--) {
		ld x, r;
		cin >> x >> r;

		while (!check.empty()) {
			ld2 prev = check.top();
			ld to_prev = rad(prev, x);
			r = min(r, to_prev);
			if (r >= prev[1]) check.pop();
			else break;
		}

		check.push({x, r});

		printf("%.3Lf\n", r);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB 505 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB 2000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 856 KB 20000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1844 KB 50000 numbers
2 Correct 37 ms 1860 KB 49912 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 2820 KB 100000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 3360 KB 115362 numbers
2 Correct 75 ms 3552 KB 119971 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 4176 KB 154271 numbers
2 Correct 125 ms 5596 KB 200000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 4688 KB 200000 numbers
2 Correct 143 ms 5500 KB 199945 numbers