Submission #500983

# Submission time Handle Problem Language Result Execution time Memory
500983 2022-01-01T21:41:17 Z danielsuh Balloons (CEOI11_bal) C++17
0 / 100
154 ms 9280 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

long double get_radius(int r_1, int x_1, int y_1, int x_2) {
	ll num = pow(r_1, 2) - pow(x_1, 2) + 2 * x_1 * x_2 - pow(x_2, 2) - pow(y_1, 2);
	ll den = 2 * (y_1 + r_1);
	return (long double) -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, int>> 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]);
		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 Incorrect 0 ms 204 KB 5th numbers differ - expected: '17.1630000000', found: '4.3710000000', error = '12.7920000000'
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB 2nd numbers differ - expected: '252735385.4379999936', found: '1000000000.0000000000', error = '747264614.5620000362'
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB 3rd numbers differ - expected: '0.0420000000', found: '2.0830000000', error = '2.0410000000'
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 320 KB 3rd numbers differ - expected: '121.0000000000', found: '120.0180000000', error = '0.9820000000'
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 1072 KB 3rd numbers differ - expected: '211.0000000000', found: '210.0110000000', error = '0.9890000000'
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 2604 KB 5th numbers differ - expected: '15395.0000000000', found: '15396.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 4912 KB 3rd numbers differ - expected: '7936.0000000000', found: '6084.6240000000', error = '1851.3760000000'
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 5736 KB 5th numbers differ - expected: '5054.0000000000', found: '5055.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 7556 KB 3rd numbers differ - expected: '1872.0000000000', found: '1871.0010000000', error = '0.9990000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 154 ms 9280 KB 3rd numbers differ - expected: '2960.0000000000', found: '2959.0010000000', error = '0.9990000000'
2 Halted 0 ms 0 KB -