Submission #442661

# Submission time Handle Problem Language Result Execution time Memory
442661 2021-07-08T14:18:47 Z oneskovic Balloons (CEOI11_bal) C++14
10 / 100
2000 ms 3964 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 * prev_radius)) / 2.0;
			if (radius_to_intersect < max_radius)
			{
				max_radius = radius_to_intersect;
			}
		}
		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 Incorrect 1 ms 204 KB 5th numbers differ - expected: '17.1630000000', found: '4.3706900000', error = '12.7923100000'
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 5th numbers differ - expected: '0.1170000000', found: '0.0833300000', error = '0.0336700000'
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 352 KB 3rd numbers differ - expected: '121.0000000000', found: '120.0182900000', error = '0.9817100000'
# Verdict Execution time Memory Grader output
1 Incorrect 422 ms 792 KB 3rd numbers differ - expected: '211.0000000000', found: '210.0105600000', error = '0.9894400000'
# Verdict Execution time Memory Grader output
1 Execution timed out 2087 ms 1568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2082 ms 2476 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 2592 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2097 ms 3188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2091 ms 3964 KB Time limit exceeded
2 Halted 0 ms 0 KB -