Submission #525596

# Submission time Handle Problem Language Result Execution time Memory
525596 2022-02-12T05:40:21 Z Tam_theguide Balloons (CEOI11_bal) C++14
100 / 100
343 ms 14908 KB
//dung stack de tim voi tat ca cac phan tu trong mang:
//phan tu gan nhat ve phia ben trai nho hon a[i]/lon hon a[i];
//stack chi tim duoc gan nhat
//tinh chat monotone:
//gia su khi them vao phan tu a[i] ta pop stack den phan tu a[j] thi cac phan tu a[t] sao cho j<t<i la mot day don dieu (MONOTONE)
//do ta pop tu a[i] den a[j] va pop het cac phan tu a[t] suy ra cac phan tu a[t] phai cung thoa man mot tinh chat nao neu khong thi khi them vao mot phan tu trong doan a[t] thi ta buoc phai pop mot so phan tu khac do mau thuan ve tinh chat

#include <bits/stdc++.h>
using namespace std;
stack<pair<long double, long double>>potential;
long double process(long double x, long double r){
    while (!potential.empty()){
        r=min(r, ((x-potential.top().first)*(x-potential.top().first))/(4*potential.top().second));
        if (r>potential.top().second) potential.pop();
        else break;
    }
    potential.push({x, r});
    return r;
}


int n;
long double x[300005];
long double r[300005];
int main(){
    cin>>n;
    for (int i=1;i <=n; i++){
        cin>>x[i]>>r[i];
    }
    for (int i=1;i <=n; i++){
        cout<<fixed<<setprecision(3)<<process(x[i], r[i])<<'\n';
    }
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1324 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 98 ms 3304 KB 50000 numbers
2 Correct 87 ms 3908 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 170 ms 5996 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 185 ms 6888 KB 115362 numbers
2 Correct 210 ms 9080 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 250 ms 8904 KB 154271 numbers
2 Correct 343 ms 14908 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 322 ms 10920 KB 200000 numbers
2 Correct 332 ms 14908 KB 199945 numbers