제출 #1314311

#제출 시각아이디문제언어결과실행 시간메모리
1314311kingboyBalloons (CEOI11_bal)C++20
30 / 100
329 ms1540 KiB
#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++) {
        double xpos, maxRadius;
        cin >> xpos >> maxRadius;

        while (!st.empty()) {
            double maxAllowableRadius = (xpos-st.top().first) * (xpos-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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...