Submission #492243

# Submission time Handle Problem Language Result Execution time Memory
492243 2021-12-06T05:53:32 Z darkowl Balloons (CEOI11_bal) C++14
100 / 100
243 ms 8560 KB
/// I in it to win it !

#include <bits/stdc++.h>
using namespace std;

#define ll                       long long
#define int ll
#define F                        first
#define S                        second
#define mp                       make_pair
#define pii                      pair<int, int>
#define pb                       push_back
#define pf                       push_front
#define arr_fill(a, n)           for(ll i = 0 ; i < n ; i++){cin >> a[i];}
#define arr_fill_sum(a,n,sum)    for (ll i = 0 ; i < n ; i++){cin >> a[i];sum+=a[i];}
#define arr_out(a,n)             for (ll i = 0 ; i < n ; i++){cout << a[i] <<" ";}
#define fast                     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAXN = 1e6 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 7;
ll pw(ll a, ll b){return b == 0 ? 1LL : (pw(a * a  , b / 2) * (b % 2 == 0 ? 1LL : a));}
stack < pair<int, double> > s;
double vd, x[MAXN], r[MAXN];

void solve ()
{
    int n; cin >> n ;
    cout << fixed << setprecision(3);
    cin >> x[0] >> r[0];
    s.push({0, r[0]}); cout << r[0] <<"\n";
    for(int i = 1; i < n; i++)
    {
        cin >> x[i] >> r[i];
        while (!s.empty())
        {
            r[i] = min(r[i], ((double)(pw(x[i] - x[s.top().F], 2)/(4 * (s.top().S)))));
            if ( r[i] >= s.top().S){s.pop();}
            else {break;}
        }
        s.push({i, r[i]});
        cout << r[i] <<"\n";
    }
}
int32_t main()
{
    fast
    int t = 1; //cin >> t;
    while (t--)
    {
        solve();
    }
    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 21 ms 776 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 54 ms 1672 KB 50000 numbers
2 Correct 50 ms 2324 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 114 ms 2768 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 129 ms 3304 KB 115362 numbers
2 Correct 125 ms 5188 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 173 ms 4176 KB 154271 numbers
2 Correct 212 ms 8520 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 243 ms 5016 KB 200000 numbers
2 Correct 207 ms 8560 KB 199945 numbers