Submission #407138

# Submission time Handle Problem Language Result Execution time Memory
407138 2021-05-18T14:47:14 Z julian33 Balloons (CEOI11_bal) C++14
100 / 100
172 ms 5384 KB
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}

const int mxN=2e5+5;

stack<pair<ll,double>> stk;
ll n,r,x;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>r;
        double ans=r;
        while(sz(stk)){
            pair<ll,double> cur=stk.top();
            double nr=(cur.first-x)*(cur.first-x)/(4*cur.second);
            mina(ans,nr);
            if(ans>=cur.second)
                stk.pop();
            else
                break;
        }
        cout<<fixed<<setprecision(3)<<ans<<"\n";
        stk.push({x,ans});
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 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 18 ms 688 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1580 KB 50000 numbers
2 Correct 39 ms 1548 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 92 ms 2656 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 109 ms 3108 KB 115362 numbers
2 Correct 98 ms 3436 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 141 ms 4044 KB 154271 numbers
2 Correct 154 ms 5384 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 172 ms 4552 KB 200000 numbers
2 Correct 152 ms 5380 KB 199945 numbers