Submission #500989

# Submission time Handle Problem Language Result Execution time Memory
500989 2022-01-01T21:48:21 Z danielsuh Balloons (CEOI11_bal) C++17
100 / 100
237 ms 16184 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(10);
	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);
			long double test = (x1 - A[i].first) * (x1 - A[i].first) / (4LL * r1);
			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 32 ms 1544 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 58 ms 3764 KB 50000 numbers
2 Correct 52 ms 4288 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 122 ms 6836 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 143 ms 7912 KB 115362 numbers
2 Correct 133 ms 9820 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 187 ms 10184 KB 154271 numbers
2 Correct 217 ms 16172 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 237 ms 12732 KB 200000 numbers
2 Correct 208 ms 16184 KB 199945 numbers