Submission #401357

# Submission time Handle Problem Language Result Execution time Memory
401357 2021-05-10T02:17:00 Z benk Balloons (CEOI11_bal) C++14
10 / 100
198 ms 9072 KB
#include "bits/stdc++.h"
using namespace std;

#define all(x)      x.begin(), x.end()
#define pb          push_back
#define sz(x)       (int)(x.size())
#define ll          long long
#define fi          first
#define se          second
#define lbd         lower_bound
#define ubd         upper_bound

const int MOD = 1e9 + 7;
const double eps = 1e-10;
const long long INF = 1e18;
const int N = 2e5 + 10;


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

	stack<pair<int, int>> s;
	for (int i = 0; i < n; i++) {
		bool ok = 0;
		ll tmp;
		while (!s.empty()) {
			tmp = 1LL * (x[i] - s.top().fi) * (x[i] - s.top().fi);
			if (tmp / 4LL * s.top().se < r[i]) s.pop();
			else break;
		}
		double ans;
		if (s.empty()) ans = r[i];
		else ans = min(1.0 * r[i], tmp / (4.0 * s.top().se));
		cout << fixed << setprecision(10) << ans << '\n';
		s.push({x[i], r[i]});
	}
}

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

	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}

Compilation message

bal.cpp: In function 'void solve()':
bal.cpp:27:8: warning: unused variable 'ok' [-Wunused-variable]
   27 |   bool ok = 0;
      |        ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 5th numbers differ - expected: '17.1630000000', found: '4.3706896552', error = '12.7923103448'
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB 2nd numbers differ - expected: '0.0010000000', found: '3.0000000000', error = '2.9990000000'
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB 3rd numbers differ - expected: '121.0000000000', found: '120.0182926829', error = '0.9817073171'
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 1096 KB 3rd numbers differ - expected: '211.0000000000', found: '210.0105633803', error = '0.9894366197'
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 2472 KB 3rd numbers differ - expected: '15396.0000000000', found: '9489.3934618156', error = '5906.6065381844'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 4808 KB 3rd numbers differ - expected: '7936.0000000000', found: '6084.6244445518', error = '1851.3755554482'
# Verdict Execution time Memory Grader output
1 Incorrect 119 ms 5612 KB 6th numbers differ - expected: '5053.0000000000', found: '5052.0004451039', error = '0.9995548961'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 193 ms 7468 KB 3rd numbers differ - expected: '1872.0000000000', found: '1871.0012006403', error = '0.9987993597'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 198 ms 9072 KB 3rd numbers differ - expected: '2960.0000000000', found: '2959.0007596219', error = '0.9992403781'
2 Halted 0 ms 0 KB -