Submission #542989

# Submission time Handle Problem Language Result Execution time Memory
542989 2022-03-28T17:16:56 Z asdf1234coding Balloons (CEOI11_bal) C++14
100 / 100
453 ms 7156 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <iomanip>
using namespace std;

#define problemname "balloons"
#define pii pair<int,int>
#define pb push_back
#define MOD (int)1e9+7
#define ll long long
#define ff first
#define ss second

bool ckmin(double& a, double b) {return a>b?a=b,true:false;}
bool ckmax(int& a, int b) {return a<b?a=b,true:false;}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen (problemname ".in", "r", stdin); freopen(problemname ".out", "w", stdout);
    int n; cin>>n;
    stack<pair<int, double>> stacc;
    double x; double r; cin>>x>>r; stacc.push({x,r});
    vector<double> radii;
    radii.push_back(r);
    for(int i=1; i<n; i++) {
        cin>>x>>r;
        while(!stacc.empty()) {
            double topx, topr; topx=stacc.top().ff; topr=stacc.top().ss;
            ckmin(r, (x-topx)*(x-topx)/(4*topr));
            if(r>=topr) {
                stacc.pop();
            } else {
                break;
            }
        }
        stacc.push({x,r});
        radii.push_back(r);
    }

    cout<<fixed<<setprecision(3);

    for (auto x:radii) {
        cout<<x<<endl;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 6 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 47 ms 936 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 1940 KB 50000 numbers
2 Correct 145 ms 2156 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 237 ms 3512 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 270 ms 4216 KB 115362 numbers
2 Correct 273 ms 4404 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 383 ms 5336 KB 154271 numbers
2 Correct 433 ms 7144 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 453 ms 6352 KB 200000 numbers
2 Correct 442 ms 7156 KB 199945 numbers