Submission #906676

# Submission time Handle Problem Language Result Execution time Memory
906676 2024-01-14T16:52:06 Z KhanhMa Balloons (CEOI11_bal) C++14
100 / 100
161 ms 2064 KB
#include <bits/stdc++.h>
#define forr(_a,_b,_c) for(_a = _b; _a <= _c; ++_a)
#define ford(_a,_b,_c) for(_a = (_b) + 1; _a --> _c;)
#define forf(_a,_b,_c) for(_a = _b; _a < _c; ++_a)
#define ll long long
#define ull unsigned long long
#define pb push_back
using namespace std;

const int nmax = 2e5 + 5;
const ll mod = 1e9 + 7;

int i;

struct balloons{
    double x, r;
};

double radius(balloons left, balloons right){
    return (right.x - left.x)*(right.x - left.x)/(4*left.r);
}


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("main.inp", "r", stdin);
    //freopen("main.out", "w", stdout);
    int n; cin >> n;
    stack<balloons> s;
    forr(i,1,n){
        balloons a; cin >> a.x >> a.r;
        double current = a.r;
        while(!s.empty()){
            current = min(radius(s.top(), a), current);
            if(s.top().r <= current){
                s.pop();
                continue;
            } else {
                break;
            }
        }
        a.r = current;
        s.push(a);
        cout << fixed << setprecision(3) << current << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 16 ms 604 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 40 ms 860 KB 50000 numbers
2 Correct 38 ms 604 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 90 ms 1380 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 94 ms 1620 KB 115362 numbers
2 Correct 90 ms 1140 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 127 ms 1860 KB 154271 numbers
2 Correct 153 ms 1616 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 161 ms 2064 KB 200000 numbers
2 Correct 153 ms 1568 KB 199945 numbers