#include <iostream>
#include <stack>
using namespace std;
int main() {
int n;
cin >> n;
stack<pair<double, double>> st;
for (int x=0;x<n;x++) {
int xpos, maxRadius;
cin >> xpos >> maxRadius;
while (!st.empty()) {
double maxAllowableRadius = (x-st.top().first) * (x-st.top().first) / (4*st.top().second);
if (maxAllowableRadius <= maxRadius) {
maxRadius = maxAllowableRadius;
}
// covers previous balloon
if (maxRadius >= st.top().second) {
st.pop();
} else {
break;
}
}
cout << maxRadius << endl;
st.push({xpos, maxRadius});
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |