Submission #1104147

# Submission time Handle Problem Language Result Execution time Memory
1104147 2024-10-23T03:30:45 Z YudoTLE Balloons (CEOI11_bal) C++17
10 / 100
116 ms 8172 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
using vll = vector<ll>;
using vdb = vector<db>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()


void solve()
{
	int n; cin >> n;
	vll x(n); vdb r(n);
	for (int i = 0; i < n; i++)
		cin >> x[i] >> r[i];

	auto cmp = [&](int src, int i1, int i2)
	{
		ll dx1 = abs(x[src] - x[i1]);
		ll dx2 = abs(x[src] - x[i2]);

		double c1 = dx1 * dx1 * r[i2];
		double c2 = dx2 * dx2 * r[i1];

		return c1 < c2;
	};

	vi stk{0};
	for (int i = 1; i < n; i++)
	{
		while (stk.size() > 1 && cmp(i, stk[stk.size() - 2], stk.back()))
			stk.pop_back();
		
		ll dx = abs(x[stk.back()] - x[i]);
		r[i] = min(r[i], dx * dx / (r[stk.back()] * 4));
		stk.pb(i);
	}

	for (int i = 0; i < n; i++)
		cout << r[i] << " \n"[i==n-1];
}

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

	int t = 1;
	// cin >> t;
	while (t--) solve();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 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 Incorrect 1 ms 336 KB 17th numbers differ - expected: '213.0000000000', found: '234.0000000000', error = '21.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 336 KB 504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 1104 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 2516 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 54 ms 4316 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 63 ms 5072 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 88 ms 6596 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 116 ms 8172 KB 248th numbers differ - expected: '2694.0020000000', found: '2694.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -