Submission #998898

# Submission time Handle Problem Language Result Execution time Memory
998898 2024-06-14T19:55:57 Z hippo123 Balloons (CEOI11_bal) C++17
100 / 100
396 ms 11860 KB
#include <bits/stdc++.h>
using namespace std;
 
#define pr pair<double, int>
#define ll long long
#define pb push_back
#define f first
#define s second
 
 
int main(){
	int n; cin>>n;
	vector<double> x(n), r(n);
	for (int i=0;i<n; i++) cin>>x[i]>>r[i];
	
	stack<pr> st;
	double ans[n];
	for (int i=0; i<n; i++){
		double br=r[i]; 	
		while(!st.empty() ){
			br=min(br, (x[i]-st.top().s)*(x[i]-st.top().s)/(4*st.top().f));	
			if(br>st.top().f){
				st.pop();
			}
			else{
				break;
			}	
		}
		st.push({br, x[i]});		
		ans[i]=br; 
	}
	cout << fixed << setprecision(3);
	for (int i=0; i<n; i++) cout<<ans[i]<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 39 ms 988 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 96 ms 2132 KB 50000 numbers
2 Correct 102 ms 3216 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 201 ms 3540 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 229 ms 4292 KB 115362 numbers
2 Correct 247 ms 7248 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 300 ms 5400 KB 154271 numbers
2 Correct 396 ms 11860 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 392 ms 6488 KB 200000 numbers
2 Correct 393 ms 11856 KB 199945 numbers