Submission #972625

# Submission time Handle Problem Language Result Execution time Memory
972625 2024-04-30T18:59:01 Z iag99 Balloons (CEOI11_bal) C++17
100 / 100
146 ms 7140 KB
#include <bits/stdc++.h>
#define long long long

using namespace std;

double calcr(pair<double,double> pr, double xc)
{
	return (pr.first-xc)*(pr.first-xc)/(4*pr.second);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin>>n;
	stack<pair<double,double>> st;
	vector<double> ans(n);
	for(int i=0; i<n; i++)
	{
		double x,r;
		cin>>x>>r;
		double max_r=r;
		while(!st.empty())
		{
			pair<double,double> prev=st.top();
			double new_r=calcr(prev,x);
			max_r=min(new_r,max_r);
			if(max_r>=prev.second)
			{
				st.pop();
				continue;
			}
			else
			{
				break;
			}	
		}
		st.push({x, max_r});
		ans[i]=max_r;
	}
	cout<<fixed<<setprecision(3);
	for (double &r : ans) { cout << r << "\n"; }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 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 3 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 15 ms 980 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2132 KB 50000 numbers
2 Correct 42 ms 2096 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 82 ms 3536 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 96 ms 4196 KB 115362 numbers
2 Correct 84 ms 4352 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 125 ms 5308 KB 154271 numbers
2 Correct 143 ms 7140 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 145 ms 6224 KB 200000 numbers
2 Correct 146 ms 7000 KB 199945 numbers