Submission #1300798

#TimeUsernameProblemLanguageResultExecution timeMemory
1300798zowiBalloons (CEOI11_bal)C++20
10 / 100
526 ms4420 KiB
#include<bits/stdc++.h>
using namespace std;

vector<pair<double,double>> tab;
const double eps = 0.00001;

bool czy(double a,double b)
{
	double x = tab.back().first-a;
	double y = tab.back().second-b;
	double z = tab.back().second+b;
	if(x*x+y*y >= z*z)
	{
		return 0;
	}
	return 1;
}


int main()
{	
	ios_base::sync_with_stdio(0);
	int n,a,b;
	cin >> n;
	vector<double> wyn;
	for(int i = 0;i < n;++i)
	{
		cin >> a >> b;
		while(tab.size() > 0)
		{
			double l = 0.0,p = b,mid;
			for(int j = 0;j < 60;++j)
			{
				mid = (l+p)/2;
				if(czy(a,mid))
				{
					p = mid;
				}
				else
				{
					l = mid;
				}
			}
			if(l < tab.back().second) break;
			tab.pop_back();
		}
		if(tab.size() == 0)
		{
			wyn.push_back(b);
			tab.push_back({a,b});
		}
		else
		{
			double l = 0.0,p = b,mid;
			for(int j = 0;j < 60;++j)
			{
				mid = (l+p)/2;
				if(czy(a,mid))
				{
					p = mid;
				}
				else
				{
					l = mid;
				}
			}
			wyn.push_back(l);
			tab.push_back({a,l});
		}
	}
	for(double i : wyn)
	{
		cout << fixed << setprecision(3);
		cout << i << endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...