Submission #590263

# Submission time Handle Problem Language Result Execution time Memory
590263 2022-07-05T17:24:13 Z VanIOImaster153 Balloons (CEOI11_bal) C++17
100 / 100
213 ms 6620 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e5 + 5;
struct pikachu{
	double x, r;
} a[maxn];
int n;
stack<pikachu> st;

double solve(pikachu cur){
	double r1 = cur.r;
	while(!st.empty()){
		pikachu tmp = st.top();
		r1 = min(r1,(cur.x - tmp.x) * (cur.x - tmp.x) / 4 / tmp.r);
		if(r1 > tmp.r) st.pop();
		else break;
	}
	st.push((pikachu){cur.x, r1});
	return r1;
}

signed main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) { 
		cin >> a[i].x >> a[i].r;
	}
	cout << setprecision(3) << fixed << (a[0].r) << '\n';
	st.push(a[0]);
	for(int i = 1; i < n; i++){
		double res = solve(a[i]);
		cout << setprecision(3) << fixed << res << '\n';
	}
}
# 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 340 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 21 ms 892 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 59 ms 1848 KB 50000 numbers
2 Correct 62 ms 1964 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 119 ms 3088 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 120 ms 3480 KB 115362 numbers
2 Correct 119 ms 4112 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 153 ms 4420 KB 154271 numbers
2 Correct 213 ms 6620 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 192 ms 5312 KB 200000 numbers
2 Correct 202 ms 6512 KB 199945 numbers