Submission #597321

# Submission time Handle Problem Language Result Execution time Memory
597321 2022-07-15T22:04:10 Z Zian_Jacobson Balloons (CEOI11_bal) C++17
30 / 100
282 ms 10456 KB
#include<bits/stdc++.h>
using namespace std;
#define cIO ios_base::sync_with_stdio(0);cin.tie(0)
#define fileIO(x) ifstream fin(string(x)+".in"); ofstream fout(string(x)+".out")
#define ll long long
#define ld long double
#define sz(x) (int) (x).size()
#define v vector
#define pb push_back
ll bal[200001][2];//[0]=x, [1]=r
ld ans[200001] = {};
int n;
ld get_rad(int b2, int b1)//b2 is the balloon we want to inflate, b1 is the balloon we want to intersect
{
	ld rad = (ld)(bal[b2][0] - bal[b1][0]);
	return rad * rad / (ld)ans[b1] / 4;
}
int main()
{
	cin >> n;
	for (int i = 0; i <= n-1; i++)
	{
		cin >> bal[i][0] >> bal[i][1];
	}
	stack<ll> stk;//stores the indices of the big bal we need to consider

	ans[0] = (ld)bal[0][1];
	stk.push(0);
	for (int i = 1; i <= n - 1; i++)
	{
		ld next_rad = min((ld)bal[i][1], get_rad(i, stk.top()));//if this value is less than the radius of the top balloon, we can continue
		while (!stk.empty()&&next_rad > ans[stk.top()])
		{
			stk.pop();
			if (stk.empty()) break;
			next_rad = min(next_rad, get_rad(i, stk.top()));
		}
		stk.push(i);
		ans[i] = next_rad;
	}
	for (int i = 0; i <= n - 1; i++) cout << ans[i] << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 1st numbers differ - expected: '247294217.0000000000', found: '247294000.0000000000', error = '217.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 356 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1200 KB 2953rd numbers differ - expected: '1030.4380000000', found: '1030.4400000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 2956 KB 251st numbers differ - expected: '15123.0020000000', found: '15123.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 154 ms 5408 KB 285th numbers differ - expected: '7629.0020000000', found: '7629.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 154 ms 6268 KB 511th numbers differ - expected: '4494.0050000000', found: '4494.0100000000', error = '0.0050000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 8260 KB 164th numbers differ - expected: '1698.0020000000', found: '1698.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 282 ms 10456 KB 248th numbers differ - expected: '2694.0020000000', found: '2694.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -