Submission #991240

# Submission time Handle Problem Language Result Execution time Memory
991240 2024-06-01T15:51:12 Z BF001 Balloons (CEOI11_bal) C++17
100 / 100
126 ms 7052 KB
#include <bits/stdc++.h>
using namespace std;

#define N 200005
#define fi first
#define se second

typedef pair<double, double> ii;

double res[N];
int n;

double cal(ii a, double bx){
	return (bx - a.fi) * (bx - a.fi) / (4 * a.se);
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
   	stack<ii> st;
   	cin >> n;
   	for (int i = 1; i <= n; i++){
   		double r, x;
   		cin >> x >> r;
   		double mi = r;
   		while (!st.empty()){
   			ii tmp = st.top();
   			mi = min(mi, cal(tmp, x));
   			if (mi >= tmp.se) st.pop();
   			else break;
   		}
   		st.push({x, mi});
   		res[i] = mi;
   	}   

   	cout << fixed << setprecision(3) ;

   	for (int i = 1; i <= n; i++){
   		cout << res[i] << "\n";
   	}

    return 0;
}     
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 15 ms 856 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2024 KB 50000 numbers
2 Correct 32 ms 2128 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 67 ms 3548 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 90 ms 4180 KB 115362 numbers
2 Correct 76 ms 4248 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 114 ms 5232 KB 154271 numbers
2 Correct 119 ms 7052 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 126 ms 6200 KB 200000 numbers
2 Correct 121 ms 7048 KB 199945 numbers