Submission #442663

# Submission time Handle Problem Language Result Execution time Memory
442663 2021-07-08T14:20:55 Z oneskovic Balloons (CEOI11_bal) C++14
50 / 100
2000 ms 3852 KB
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;

struct stack_element
{
	double x, radius;
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n; cin >> n;
	vector<stack_element> elements(n);
	for (int i = 0; i < n; i++)
	{
		cin >> elements[i].x >> elements[i].radius;
		double new_x = elements[i].x, max_radius = elements[i].radius;
		for (int j = 0; j < i; j++)
		{
			double prev_radius = elements[j].radius;
			double prev_x = elements[j].x;
			double dx = (prev_x - new_x);
			double radius_to_intersect = (dx * dx / (2.0 * prev_radius)) / 2.0;
			if (radius_to_intersect < max_radius)
			{
				max_radius = radius_to_intersect;
			}
		}
		elements[i].radius = max_radius;
		cout << fixed << setprecision(5);
		cout << max_radius << "\n";
	}

	/*stack<stack_element> s;
	for (int i = 0; i < n; i++)
	{
		double new_x, max_radius; cin >> new_x >> max_radius;

		while (!s.empty())
		{
			double prev_radius = s.top().radius;
			double prev_x = s.top().x;
			double dx = (prev_x - new_x);
			double radius_to_intersect = (dx*dx / (2 * prev_radius)) / 2.0;
			if (radius_to_intersect < max_radius)
			{
				max_radius = radius_to_intersect;
				s.pop();
			}
			else
				break;
		}
		s.push({ new_x,max_radius });
		cout << fixed << setprecision(5);
		cout << max_radius << "\n";
	}
	*/
	return 0;
}
# 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 2 ms 204 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 7 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 398 ms 788 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 1560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2082 ms 2436 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2056 ms 2716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2088 ms 3240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2093 ms 3852 KB Time limit exceeded
2 Halted 0 ms 0 KB -