Submission #476429

# Submission time Handle Problem Language Result Execution time Memory
476429 2021-09-26T18:18:52 Z YoRepi7 Balloons (CEOI11_bal) C++17
100 / 100
522 ms 5356 KB
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using pl = pair<ll, ll>;
using pi = pair<int, int>;
using vpl = vector<pl>;
using vpi = vector<pi>;
using vc = vector<char>;
using vs = vector<string>;
 
#define forn(i, n) for(int i = 0; i < n; i++)
#define rofn(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, b, a) for(int i = b; i >= a; i--)
#define TRAV(a, x) for(auto& a: x)
#define ABC(c) for(char c = 'a'; c <= 'z'; c++)
#define all(x) begin(x), end(x)
#define sor(x) sort(all(x))
#define rsor(x) sort(all(x), greater<int>())
#define pb push_back
#define mp make_pair
#define ins insert
#define ub upper_bound
#define lb lower_bound
#define len(x) (int)(x).length()
#define sz(x) (int)(x).size()
#define f first
#define s second
#define dbg(x) TRAV(a, x) cout << a << " "
#define print(x) cout << x << endl
#define traverse(x) TRAV(a, x) cout << a.f << " " << a.s << endl
#define readvi(a, n) forn(i, n) cin >> a[i]
#define readvpi(a, n) forn(i, n) cin >> a[i].f >> a[i].s
#define gcd(a, b) __gcd(a, b)

double cost(double x1, double r1, double x2){
	return ((x1 - x2) * (x1 - x2)) / ((4 * r1));
}

void solve(){
	int n; cin >> n;
	stack<pair<double, double>> st;
	forn(i, n){
		double x, r; cin >> x >> r;
		double res = r;
		while(!st.empty()){
			res = min(res, cost(st.top().f, st.top().s, x));
			if(res >= st.top().s) st.pop();
			else break;
		}
		cout << fixed << setprecision(3) << res << endl;
		st.push({x, res});
	}
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	// int t; cin >> t;
	// forn(i, t){
	// 	solve();
	// }
	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 6 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 61 ms 608 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 140 ms 1804 KB 50000 numbers
2 Correct 124 ms 1508 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 277 ms 2740 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 321 ms 3228 KB 115362 numbers
2 Correct 313 ms 3352 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 433 ms 4036 KB 154271 numbers
2 Correct 512 ms 5356 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 516 ms 4576 KB 200000 numbers
2 Correct 522 ms 5336 KB 199945 numbers