Submission #948275

# Submission time Handle Problem Language Result Execution time Memory
948275 2024-03-18T02:54:49 Z Amaarsaa Balloons (CEOI11_bal) C++14
100 / 100
109 ms 5532 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long ;

double Find_r(double x1, double r1, double x2) {
	x1 = x1 - x2;
	x1 = x1 * x1;
	x1 = x1 / (4.0 * r1);
	return x1;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll t, x, r, max_r;
	
	cin >> t;
	
	stack < pair < double , double > > st;
	while ( t --) {
		double r, max_r;
		
		cin >> x >> r;
		max_r = r;
		
		while (!st.empty()) {
			pair < double , double > R =st.top();
			max_r = min(max_r, Find_r(R.first, R.second, x));
			if ( R.second <= max_r) st.pop();
			else break;
		}
		printf("%.3lf\n", max_r);
		st.push({x, max_r});
	}
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:16:11: warning: unused variable 'r' [-Wunused-variable]
   16 |  ll t, x, r, max_r;
      |           ^
bal.cpp:16:14: warning: unused variable 'max_r' [-Wunused-variable]
   16 |  ll t, x, r, max_r;
      |              ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 11 ms 860 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1628 KB 50000 numbers
2 Correct 28 ms 1628 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 60 ms 2900 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 76 ms 3152 KB 115362 numbers
2 Correct 61 ms 3408 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 92 ms 4180 KB 154271 numbers
2 Correct 108 ms 5456 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 109 ms 4692 KB 200000 numbers
2 Correct 101 ms 5532 KB 199945 numbers