Submission #941938

# Submission time Handle Problem Language Result Execution time Memory
941938 2024-03-09T18:43:55 Z abel2008 Balloons (CEOI11_bal) C++14
100 / 100
555 ms 5568 KB
#include <iostream>
#include <stack>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long double;
ll n,x,r,rez;
stack<pair<ll,ll>> S; // pozitia si raza pe care o are
int main() {
        cin>>n;
        cin>>x>>r;
        rez+=r;
        S.emplace(x,r);
        cout<<fixed<<setprecision(3)<<r<<'\n';
        for (int i = 2;i<=n;++i) {
                cin>>x>>r;
                ll crtr = r;
                // verificam limitele de dinainte
                bool ok = 1;
                while(ok&&!S.empty()) {
                        // calculam radius maxim fata de cercul de dinainte
                        ll maxr = pow((x-S.top().first),2LL)/(4*S.top().second);
                        crtr = min(crtr,maxr);
                        if (S.top().second<=crtr) {
                                // we can remove it and keep searching
                                ok = 1;
                                S.pop();
                        } else {
                                //
                                ok = 0;
                        }
                }
                S.emplace(x,crtr);
                rez+=crtr;
                cout<<fixed<<setprecision(3)<<crtr<<'\n';
        }
//        cout<<rez;
        return 0;
}
# 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 2 ms 600 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 51 ms 604 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 125 ms 1840 KB 50000 numbers
2 Correct 125 ms 1580 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 248 ms 2964 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 295 ms 3440 KB 115362 numbers
2 Correct 296 ms 3528 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 413 ms 4272 KB 154271 numbers
2 Correct 521 ms 5468 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 496 ms 4836 KB 200000 numbers
2 Correct 555 ms 5568 KB 199945 numbers