제출 #1207739

#제출 시각아이디문제언어결과실행 시간메모리
1207739catsarecool5530Balloons (CEOI11_bal)C++20
20 / 100
92 ms15020 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n";
#define all(x) x.begin(), x.end()
#define int long long
int MOD = 1e9 + 7;
const ll INF = 1e18;


void solve() {
    int n; cin >> n;
    vector<array<int, 2>> balloons(n);
    for (int i = 0; i < n; i++) {
        cin >> balloons[i][0] >> balloons[i][1];
    }
    vector<array<long double, 2>> stack;
    // stack[i] = {x coord, height}
    vector<long double> ans(n);
    for (int i = 0; i < n; i++) {
        int x = balloons[i][0];
        long double curLowest = 1e18;
        for (int j = stack.size() - 1; j >= 0; j--) {
            if ((x-stack[j][0]) / 2 / sqrt(stack[j][1]) < curLowest) {
                curLowest = (x - stack[j][0]) / 2 / sqrt(stack[j][1]);
                if (j < stack.size() - 1) {
                    stack.pop_back();
                }
            } else {
                break;
            }
        }
        ans[i] = min((long double) balloons[i][1], curLowest * curLowest);
        stack.push_back({(long double) x, min((long double) balloons[i][1], curLowest * curLowest)});
    }
    for (int i = 0; i < n; i++) {
        cout << fixed << setprecision(3) << ans[i] << endl;
    }





}
 
signed main() {
    ios::sync_with_stdio(0); cin.tie(NULL);
    // freopen("walk.in", "r", stdin);
    // freopen("walk.out", "w", stdout);
    ll t = 1; //cin >> t;
    while (t--) {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...