Submission #1104190

# Submission time Handle Problem Language Result Execution time Memory
1104190 2024-10-23T07:49:22 Z EkinOnal Balloons (CEOI11_bal) C++17
100 / 100
67 ms 10096 KB
//#pragma GCC optimize("O3,unroll-loops,Ofast")
//#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
 
#define MAX 200005
#define pb push_back
#define mp make_pair 
#define int long long
#define f first
#define s second
#define vi vector<int>
#define pii pair<int,int>
#define si set<int>
#define vpii vector<pair<int,int>> 
const int mod = 1e9+7;
const int INF = 1e18;
// myMap.begin()->first :  key
// myMap.begin()->second : value
 
int epow(int a,int b){int ans=1;while(b){if(b&1) ans*=a;a*=a;b>>=1;}return ans;}
int gcd(int a,int b) {if(a<b)swap(a,b);while(b){int tmp=b;b=a%b;a=tmp;}return a;}
int mul(long long a,long long b){return ((a%mod)*(b%mod))%mod;}
int sum(long long a,long long b){return ((a%mod)+(b%mod))%mod;}
 // typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
// typedef
// tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_multiset;


void solve(){
	int n; cin>>n;	
	vpii arr(n+2); for(int i=1;i<=n;i++) cin>>arr[i].f>>arr[i].s;

	stack<int> st;  vector<double> ans(n+2);
	for(int i=1;i<=n;i++){
		ans[i]=arr[i].s;
		while((int)st.size()){
			int node = st.top();
			double b = epow(arr[i].f-arr[node].f,2);
			b = b/(4.0*(double)ans[node]);
			if(b<(double)ans[i]) ans[i]=b;
			if((double)ans[i]>=(double)ans[node]) st.pop();
			else break;
		}
		st.push(i);
	}
	for(int i=1;i<=n;i++) printf("%.3lf\n",ans[i]);



  					
	return;
}
 
int32_t main(/*int32_t argc, char* argv[]*/){
	ios_base::sync_with_stdio(0); cin.tie(0);
	// freopen("dining.in", "r", stdin);
	// freopen("dining.out", "w", stdout);		
 
	int t=1;
//	cin >> t;
	while (t--) solve();
 
	return 0;	 			
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 9 ms 848 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2128 KB 50000 numbers
2 Correct 15 ms 2896 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3540 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 42 ms 4168 KB 115362 numbers
2 Correct 35 ms 6216 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 59 ms 5464 KB 154271 numbers
2 Correct 57 ms 10096 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 67 ms 6728 KB 200000 numbers
2 Correct 57 ms 10056 KB 199945 numbers