Submission #500020

# Submission time Handle Problem Language Result Execution time Memory
500020 2021-12-30T09:27:58 Z BBart888 Balloons (CEOI11_bal) C++14
100 / 100
170 ms 9348 KB
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include<stack>
#include <set>
#include <cmath>
#include <string>
#include <iomanip>


using namespace std;
using ll = long long;
#define rev(x) reverse(x.begin(),x.end())
#define FOR(i,n) for(int i = 0;i<n;i++)
#define all(x) x.begin(),x.end()

const int INF = 1e9;
const int MAXN = 2e5+111;
const int MOD = 1e9 + 7;
const int MAXS = 250*1000+123;
const pair<int, int> dd[]{ {0,1},{0,-1},{1,0},{-1,0} };



int n;
long double r[MAXN];
int x[MAXN];
long double ans[MAXN];
stack<pair<long double, int>> st;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("fencedin.in", "r", stdin);
    //freopen("fencedin.out", "w", stdout);

    
    cout << fixed << setprecision(3);

    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> x[i] >> r[i];


    for (int i = 0; i < n; i++)
    {
        while (!st.empty())
        {
            pair<long double, int> s = st.top();
            r[i] = min(r[i],pow((s.second-x[i]),2)/(4*s.first));
            if (r[i] >= s.first)st.pop();
            else break;
        }
        st.push({r[i],x[i]});
        cout << r[i] << " ";
    }
















    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 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 20 ms 864 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 54 ms 2120 KB 50000 numbers
2 Correct 44 ms 2648 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 111 ms 3396 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 99 ms 3904 KB 115362 numbers
2 Correct 113 ms 5784 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 148 ms 4856 KB 154271 numbers
2 Correct 163 ms 9348 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 170 ms 5772 KB 200000 numbers
2 Correct 156 ms 9276 KB 199945 numbers