Submission #501879

# Submission time Handle Problem Language Result Execution time Memory
501879 2022-01-04T17:57:36 Z perchuts Balloons (CEOI11_bal) C++17
100 / 100
217 ms 14976 KB
#include <bits/stdc++.h>
#define maxn (int)(1e5+51)
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define ll long long
#define pb push_back
#define ull unsigned long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define inf 2000000001
#define mod 1000000007 //998244353
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }

long double rad[2*maxn],v[2*maxn];
int main(){_
    //freopen("in.in", "r", stdin);
    //freopen("out.out", "w", stdout);
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>v[i]>>rad[i];
    }
    stack<pair<long double,long double>>st;
    for(int i=1;i<=n;i++){
        long double d = v[i];
        long double r = rad[i];
        while(!st.empty()){
            ckmin(r,(d-st.top().second)*(d-st.top().second)/(4*st.top().first));
            if(r<=st.top().first)break;
            else st.pop();
        }
        cout<<fixed<<setprecision(3)<<r<<endl;
        st.push({r,d});
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 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 20 ms 1272 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 75 ms 3272 KB 50000 numbers
2 Correct 48 ms 3936 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 110 ms 6112 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 124 ms 6984 KB 115362 numbers
2 Correct 133 ms 9084 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 163 ms 9028 KB 154271 numbers
2 Correct 193 ms 14916 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 217 ms 10952 KB 200000 numbers
2 Correct 194 ms 14976 KB 199945 numbers