Submission #956311

# Submission time Handle Problem Language Result Execution time Memory
956311 2024-04-01T14:36:47 Z codefox Balloons (CEOI11_bal) C++14
100 / 100
446 ms 5528 KB
#include<bits/stdc++.h>

using namespace std;

#define pii pair<int, double>
#define ll long long

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cout << fixed;
    cout << setprecision(3);

    int n;
    cin >> n;
    stack<pii> balloons;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        double sol = b;
        while (balloons.size())
        {
            ll dn = a-balloons.top().first;
            double r = balloons.top().second;
            if ((r+b)*(r+b) >= dn*dn+(r-b)*(r-b)) 
            {
                sol = min(sol, (dn*dn)/(4*r));
            }
            if (r>sol)break;
            balloons.pop();
        }
        balloons.push({a, sol});
        cout << sol << "\n";
    }
}
# 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 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 42 ms 348 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 107 ms 848 KB 50000 numbers
2 Correct 108 ms 1572 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 220 ms 1392 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 251 ms 1364 KB 115362 numbers
2 Correct 273 ms 3604 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 339 ms 1876 KB 154271 numbers
2 Correct 436 ms 5528 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 446 ms 2128 KB 200000 numbers
2 Correct 436 ms 5460 KB 199945 numbers