Submission #447495

# Submission time Handle Problem Language Result Execution time Memory
447495 2021-07-26T15:05:40 Z rieyuw Balloons (CEOI11_bal) C++17
20 / 100
270 ms 8912 KB
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <unordered_set>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <climits>
#include <queue>
#include <array>

using namespace std;

#define f first
#define s second
const int mxN = 1000;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
/*Problem: */

void solve() {}

void Inflate(stack<pair<int, double>>& stk, int&  x, double& r)
{
	
}

int main()
{
	ios::sync_with_stdio(0), cin.tie(0);
	//freopen("paintbarn.in", "r", stdin);
	//freopen("paintbarn.out", "w", stdout);	
	//int t = 1; cin >> t; while (t--) solve();

	int n; cin >> n;
	vector<int> x(n); vector<double> dia(n);
	for (int i = 0; i < n; ++i)
		cin >> x[i] >> dia[i];

	stack<pair<int, double>> stk;
	
	for (int i = 0; i < n; ++i)
	{
		while (!stk.empty())
		{
			int x1 = stk.top().f;
			double r1 = stk.top().s;
			//dia[i] = min(dia[i], (x1 - x[i]) / 4.0 * r1 * (x1 - x[i]));
			dia[i] = min(dia[i], (x1 - x[i]) * (x1 - x[i]) / (4.0 * r1));
			//cout << "i: " << i << ", x1: " << x1 << ", r1: " << r1 << "\n";
			//cout << "Calc: " << (x1 - x[i]) / 4.0 * r1 * (x1 - x[i]) << "\n";
			//cout << "Calc: " << (x1 - x[i]) * (x1 - x[i]) / (4.0 * r1) << "\n";
			//cout << "i: " << i << ", dia[i]: " << dia[i] << ", r1: " << r1 << "\n";
			if (dia[i] >= r1) stk.pop();
			else break;
		}
		stk.push({ x[i], dia[i] });
	}
	for (int i = 0; i < n; ++i)
	{
		cout << fixed << setprecision(3) << dia[i] << "\n";
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB 2nd numbers differ - expected: '252735385.4379999936', found: '0.9330000000', error = '252735384.5049999952'
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB 506th numbers differ - expected: '365.0000000000', found: '-2481854.0649999999', error = '2482219.0649999999'
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1104 KB 655th numbers differ - expected: '591.0000000000', found: '-2402336.3029999998', error = '2402927.3029999998'
# Verdict Execution time Memory Grader output
1 Incorrect 60 ms 2224 KB 4th numbers differ - expected: '15396.0000000000', found: '-8148.5510000000', error = '23544.5510000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 4516 KB 7234th numbers differ - expected: '7160.0000000000', found: '-2398141.9989999998', error = '2405301.9989999998'
# Verdict Execution time Memory Grader output
1 Incorrect 163 ms 4988 KB 4643rd numbers differ - expected: '2427.0000000000', found: '-2355611.7020000000', error = '2358038.7020000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 190 ms 6596 KB 1734th numbers differ - expected: '1856.0220000000', found: '-2324667.3859999999', error = '2326523.4079999998'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 270 ms 8912 KB 2723rd numbers differ - expected: '859.0470000000', found: '-2333711.4849999999', error = '2334570.5319999997'
2 Halted 0 ms 0 KB -