Submission #703195

# Submission time Handle Problem Language Result Execution time Memory
703195 2023-02-26T14:08:25 Z Markomafko972 Balloons (CEOI11_bal) C++14
100 / 100
188 ms 8548 KB
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

int n;
int pos;
long double r;
stack< pair<long double, int> > s;
long double sol[200005];

int main () {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> pos >> r;
		long double naj = r;
		while (s.size() > 0) {
			long double tren = s.top().Y-pos;
			tren *= tren;
			tren /= 4;
			tren /= s.top().X;
		
			if (tren <= naj) {
				if (tren < s.top().X) {
					naj = min(naj, tren);
					break;
				}
				else {
					s.pop();
					//if (tren > naj) break;
					naj = min(naj, tren);
				}
			}
			else {
				if (naj < s.top().X) break;
				else s.pop();
			}
		}
		sol[i] = naj;
		s.push({naj, pos});
	}
	
	for (int i = 0; i < n; i++) cout << fixed << setprecision(3) << sol[i] << "\n";

	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 328 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 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 16 ms 1048 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2520 KB 50000 numbers
2 Correct 50 ms 2336 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 90 ms 4448 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 101 ms 5072 KB 115362 numbers
2 Correct 111 ms 5384 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 131 ms 6540 KB 154271 numbers
2 Correct 188 ms 8548 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 167 ms 7776 KB 200000 numbers
2 Correct 170 ms 8504 KB 199945 numbers