Submission #394903

# Submission time Handle Problem Language Result Execution time Memory
394903 2021-04-27T13:00:07 Z ak2006 Balloons (CEOI11_bal) C++14
100 / 100
184 ms 16412 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
const ll mod = 1e9 + 7,inf = 1e18;
const ld eps = 1e-3;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n = 2e5 + 5;
vvi a(n,vi(2));
int main()
{
    fast;
    cin>>n;
    for (int i = 0;i<n;i++)cin>>a[i][0]>>a[i][1];
    deque<pair<ld,ld>>st;
    for (int i = 0;i<n;i++){
        if (st.empty()){
            st.push_back({a[i][0],a[i][1]});
            cout<<fixed<<setprecision(3)<<a[i][1]<<'\n';
            continue;
        }
        else{
            ld ri = a[i][1],xi = a[i][0];
            while (!st.empty()){
                ld rj = st.back().second,xj = st.back().first;
                ri = min(ri,((xj - xi) * (xj - xi)) / (4 * rj));
                if ((ri - rj) < -eps)break;
                st.pop_back();
            }
            st.push_back({xi,ri});
            cout<<fixed<<setprecision(3)<<ri<<'\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11208 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 15 ms 11212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 17 ms 11224 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 40 ms 11408 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 59 ms 12048 KB 50000 numbers
2 Correct 63 ms 12648 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 103 ms 12300 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 125 ms 12588 KB 115362 numbers
2 Correct 107 ms 14364 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 155 ms 12816 KB 154271 numbers
2 Correct 167 ms 16412 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 184 ms 12868 KB 200000 numbers
2 Correct 172 ms 16380 KB 199945 numbers