Submission #1098706

# Submission time Handle Problem Language Result Execution time Memory
1098706 2024-10-09T18:44:59 Z sano Balloons (CEOI11_bal) C++14
100 / 100
207 ms 11676 KB
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<fstream>
#include<algorithm>
#include <iomanip>
#include<map>
#include <set>
#include <unordered_map>
#include <stack>
#include <unordered_set>
#include <cmath>
#define ll long long
#define For(i, n) for(int i = 0; i < (int)n; i++)
#define ffor(i, a, n) for(int i = (int)a; i < (int)n; i++)
#define rfor(i, n) for(int i = (int)n; i >= (int)0; i--)
#define rffor(i, a, n) for(int i = (int)n; i >= (int)a; i--)
#define vec vector
#define ff first
#define ss second
#define pb push_back
#define shit short int
#define pii pair<int, int>
#define NEK 2147483640
#define mod 1000000007
#define mod2 1000000009
#define rsz resize 
#define prv1 43
#define prv2 47
#define D 8

using namespace std;

int main() {
	int n;
	cin >> n;
	vec<long double> x(n), r(n);
	For(i, n) cin >> x[i] >> r[i];
	stack<int> s;
	For(i, n) {
		while (!s.empty()) {
			long double r2 = (x[i] - x[s.top()]) * (x[i] - x[s.top()]) / 4 / r[s.top()];
			r[i] = min(r2, r[i]);
			if (r[i] >= r[s.top()]) s.pop();
			else break;
		}
		s.push(i);
	}
	cout << fixed << setprecision(3);
	For(i, n) cout << r[i] << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1116 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 47 ms 2384 KB 50000 numbers
2 Correct 49 ms 3156 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 101 ms 4344 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 117 ms 5072 KB 115362 numbers
2 Correct 131 ms 7260 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 149 ms 6484 KB 154271 numbers
2 Correct 207 ms 11676 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 181 ms 8272 KB 200000 numbers
2 Correct 202 ms 11604 KB 199945 numbers