Submission #1006935

# Submission time Handle Problem Language Result Execution time Memory
1006935 2024-06-24T10:02:31 Z jor0715 Balloons (CEOI11_bal) C++17
100 / 100
133 ms 11860 KB
#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007
#define ll long long
#define endl "\n"
#define range(i,a,b,c) for(int i=a;i!=b;i+=c)
#define vi vector<int>
#define vll vector<ll>

long double r2(long double r1, long double x1, long double x2){
	int dis = abs(x2-x1);
	return 1.0*pow(dis,2)/(4*r1);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cout << fixed << setprecision(3);
	
	int N;
	cin >> N;
	vector<long double> x(N);
	vector<long double> r(N);
	range(i,0,N,1){
		cin >> x[i] >> r[i];
	}
	
	stack<pair<long double, int>> st;
	
	st.push({r[0],x[0]});
	cout << r[0] << endl;
	
	range(i,1,N,1){
		long double minn = min(r[i], r2(st.top().first, st.top().second, x[i]));
		
		while(st.top().first <= minn){
			st.pop();
			if(st.empty()) break;
			minn = min(minn, r2(st.top().first, st.top().second, x[i]));
		}
		
		st.push({minn, x[i]});
		cout << minn << endl;
	}
	
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1116 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2644 KB 50000 numbers
2 Correct 30 ms 3156 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 65 ms 4696 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 78 ms 5212 KB 115362 numbers
2 Correct 69 ms 7252 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 104 ms 6736 KB 154271 numbers
2 Correct 117 ms 11704 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 133 ms 8276 KB 200000 numbers
2 Correct 117 ms 11860 KB 199945 numbers