Submission #575144

# Submission time Handle Problem Language Result Execution time Memory
575144 2022-06-09T18:35:15 Z alexz1205 Balloons (CEOI11_bal) C++14
100 / 100
556 ms 15244 KB
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

typedef long double lint;

lint dist(lint p1, lint p2, lint r1){
	return (p1-p2)*(p1-p2)/4/r1;
}

int main() {
	int n;
	cin >> n;
	lint pos[n], maxr[n], rad[n];
	for (int x = 0; x < n; x ++){
		cin >> pos[x] >> maxr[x];
	}
	vector<int> stack;
	for (int x = 0; x < n; x ++){
		rad[x] = maxr[x];
		while (!stack.empty()){
			int y = stack.back();
			rad[x] = min(dist(pos[y], pos[x], rad[y]), rad[x]);
			if (rad[x] > rad[y]){
				stack.pop_back();
			}else {
				break;
			}
		}
		stack.push_back(x);
	}
	for (int x = 0; x < n; x ++){
		cout << fixed << setprecision(3) << rad[x] << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 6 ms 440 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 57 ms 1512 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 158 ms 3484 KB 50000 numbers
2 Correct 146 ms 4032 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 283 ms 6256 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 322 ms 7188 KB 115362 numbers
2 Correct 340 ms 9372 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 421 ms 9332 KB 154271 numbers
2 Correct 554 ms 15236 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 532 ms 11740 KB 200000 numbers
2 Correct 556 ms 15244 KB 199945 numbers