Submission #653871

# Submission time Handle Problem Language Result Execution time Memory
653871 2022-10-28T16:54:25 Z zxcvbnm Balloons (CEOI11_bal) C++14
100 / 100
200 ms 8124 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<long double> x(n), r(n);
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> r[i];
	}
	
	stack<int> st;
	for(int i = 0; i < n; i++) {
		long double curr = r[i];
		while(!st.empty()) {
			int idx = st.top();
			curr = min(curr, (long double) ((x[i] - x[idx]) * (x[i] - x[idx])) / (4.00 * r[idx]));
			if (r[idx] <= curr) {
				st.pop();
			}
			else {
				break;
			}
		} 
		r[i] = curr;
		st.push(i);
		cout << fixed << setprecision(3) << curr << "\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 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1100 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 57 ms 2284 KB 50000 numbers
2 Correct 58 ms 2184 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 113 ms 4352 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 133 ms 4932 KB 115362 numbers
2 Correct 121 ms 4736 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 176 ms 6456 KB 154271 numbers
2 Correct 195 ms 7756 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 200 ms 8124 KB 200000 numbers
2 Correct 190 ms 7756 KB 199945 numbers