Submission #810186

# Submission time Handle Problem Language Result Execution time Memory
810186 2023-08-06T06:00:50 Z darklight Balloons (CEOI11_bal) C++14
100 / 100
524 ms 8608 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h> 
using namespace std;
#define int long double
typedef long long ll;
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
int cal(pair<int,int> a,int bx) {
	return (a.first-bx)*(a.first-bx)/(4*a.second);
}

void solve(){
    int n;cin>>n;
    vector<int> ans(n);
	stack<pair<int,int>> s;
	for(int i=0;i<n;i++){
		int x,r;cin>>x>>r;
		int max_radius=r;
		while(!s.empty()){
			pair<int,int> last=s.top();
			int curr=cal(last,x);
			max_radius=min(max_radius,curr);
            if(max_radius>=last.second){
				s.pop();continue;
			}
			else break;
		}
		s.push({x, max_radius});
		ans[i]=max_radius;
	}
	cout<<fixed<<setprecision(3);
	for(auto &x:ans) cout<<x<<endl;
}
 
int32_t main(){
    // freopen('input.txt','r',stdin);
    // freopen('output.txt','w',stdout);
    solve();
    // 48-57:0-9 / 65-90:A-Z / 97-122:a-z
    // DECIMAL:       cout<<fixed<<setprecision(8)<<ans;
    // PREFIX+SUFFIX: exclude a element in the array
    // PREFIX_SUM:    binary array
    // DFS/BFS:       states being visited again
    // BINARY_SEARCH: maximize the minimum possible/minimize the maximum possible
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 304 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 7 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 46 ms 992 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 124 ms 2592 KB 50000 numbers
2 Correct 117 ms 2404 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 232 ms 4428 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 266 ms 5048 KB 115362 numbers
2 Correct 295 ms 5348 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 361 ms 6540 KB 154271 numbers
2 Correct 482 ms 8520 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 454 ms 7812 KB 200000 numbers
2 Correct 524 ms 8608 KB 199945 numbers