Submission #741296

# Submission time Handle Problem Language Result Execution time Memory
741296 2023-05-14T01:29:39 Z hafo Balloons (CEOI11_bal) C++14
100 / 100
189 ms 8580 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pa pair<int, int>
#define pall pair<ll, int>
#define fi first
#define se second
#define TASK "test"
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;}
template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;}

const int MOD = 1e9 + 7;
const int LOG = 20;
const int maxn = 2e5 + 7;
const ll oo = 1e18 + 69;

int n;
double r[maxn], x[maxn];

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

    //freopen(TASK".inp", "r", stdin);
    //freopen(TASK".out", "w", stdout);

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

    stack<pair<int, double>> st;
    for(int i = 0; i < n; i++) {
        double rr = r[i];
        while(!st.empty()) {
            int x2 = st.top().fi;
            double r2 = st.top().se;
            mini(rr, (x2 - x[i]) * (x2 - x[i]) / (r2 * 4.0));
            if(rr >= r2) st.pop();
            else break;
        }
        cout<<setprecision(3)<<fixed<<rr<<"\n";
        st.push({x[i], rr});
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 21 ms 692 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 54 ms 1644 KB 50000 numbers
2 Correct 45 ms 2348 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 104 ms 2840 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 3288 KB 115362 numbers
2 Correct 106 ms 5232 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 152 ms 4144 KB 154271 numbers
2 Correct 176 ms 8516 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 189 ms 5060 KB 200000 numbers
2 Correct 174 ms 8580 KB 199945 numbers