Submission #1314310

#TimeUsernameProblemLanguageResultExecution timeMemory
1314310kingboyBalloons (CEOI11_bal)C++20
0 / 100
239 ms1108 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++) {
        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 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...