Submission #500987

# Submission time Handle Problem Language Result Execution time Memory
500987 2022-01-01T21:46:19 Z danielsuh Balloons (CEOI11_bal) C++17
50 / 100
204 ms 11316 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int long double

long double get_radius(int r_1, int x_1, int y_1, int x_2) {
	long double num = pow(r_1, 2LL) - pow(x_1, 2LL) + 2LL * x_1 * x_2 - pow(x_2, 2LL) - pow(y_1, 2LL);
	long double den = 2LL * (y_1 + r_1);
	return -num / den;
}

void solve() {
	cout << fixed << setprecision(3);
	int N; cin >> N;
	vector<pair<int, int>> A(N); for(auto &x : A) cin >> x.first >> x.second;
	vector<long double> ans(N);
	stack<pair<int, long double>> st;
	for(int i = 0; i < N; i++) {
		long double r = A[i].second;
		while(!st.empty()) {
			int r1 = st.top().second, x1 = st.top().first;
			long double test = get_radius(r1, x1, r1, A[i].first);
			r = min(r, test);
			if(r >= r1) {
				st.pop();
			}else {
				break;
			}
		}
		st.push({A[i].first, r});
		ans[i] = r;
	}
	for(auto &x : ans) cout << x << "\n";
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve();
    }
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1424 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 3364 KB 14176th numbers differ - expected: '0.7720000000', found: '0.7700000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 6076 KB 14857th numbers differ - expected: '7169.6020000000', found: '7169.6090000000', error = '0.0070000000'
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 7104 KB 23610th numbers differ - expected: '1467.9600000000', found: '1467.9430000000', error = '0.0170000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 9244 KB 18635th numbers differ - expected: '3964.4000000000', found: '3964.3960000000', error = '0.0040000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 204 ms 11316 KB 29994th numbers differ - expected: '3138.3710000000', found: '3138.3730000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -