Submission #772106

# Submission time Handle Problem Language Result Execution time Memory
772106 2023-07-03T16:12:22 Z NK_ Balloons (CEOI11_bal) C++17
100 / 100
148 ms 3428 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

using ld = long double;

const ld eps = 1e-9;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	cout << fixed << setprecision(10);
	int N; cin >> N;

	vector<pair<int, ld>> A;

	for(int i = 0; i < N; i++) {
		int x, r; cin >> x >> r;

		ld ans = r;
		while(size(A)) {
			ld D = ld(x - A.back().first) * ld(x - A.back().first);
			ld R = min(ld(r), D / (4 * A.back().second));
			if ((ans - R) > eps) ans = R;
			// cout << ans - R << " - " << x << endl;

			if (ans+eps > A.back().second) A.pop_back();
			else break;
		}

		cout << ans << nl;

		A.push_back({x, ans});
	}

    return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 14 ms 604 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1484 KB 50000 numbers
2 Correct 40 ms 1008 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 73 ms 2152 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 84 ms 2568 KB 115362 numbers
2 Correct 72 ms 1920 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 116 ms 3096 KB 154271 numbers
2 Correct 131 ms 2960 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 148 ms 3428 KB 200000 numbers
2 Correct 118 ms 3028 KB 199945 numbers