Submission #473111

# Submission time Handle Problem Language Result Execution time Memory
473111 2021-09-15T07:44:56 Z MohammadAghil Balloons (CEOI11_bal) C++14
100 / 100
274 ms 15392 KB
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
#define rep(i,l,r) for(int i = (l); i < r; i++)
#define per(i,r,l) for(int i = (r); i >= l; i--)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define ss second 
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
const ll mod = 1e9 + 7, maxn = 2e3 + 10, inf = 1e18;

int main(){
    cin.tie(0) -> sync_with_stdio(0);
    int n; cin >> n;
    vector<long double> x(n), r(n), st, ans(n);
    rep(i,0,n){
        cin >> x[i] >> r[i];
    }
    cout << fixed << setprecision(5);
    rep(i,0,n){
        long double rx = r[i];
        while(sz(st)){
            rx = min(rx, (long double)(x[i] - x[st.back()])*(x[i] - x[st.back()])/(4.*ans[st.back()]));
            if(rx >= ans[st.back()]) st.pop_back();
            else break;
        }
        ans[i] = rx;
        st.pb(i);
        cout << ans[i] << ' ';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 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 3 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1476 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 68 ms 3396 KB 50000 numbers
2 Correct 67 ms 4164 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 138 ms 6212 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 175 ms 7280 KB 115362 numbers
2 Correct 156 ms 9284 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 222 ms 9496 KB 154271 numbers
2 Correct 259 ms 15220 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 274 ms 11888 KB 200000 numbers
2 Correct 261 ms 15392 KB 199945 numbers