제출 #1077178

#제출 시각아이디문제언어결과실행 시간메모리
1077178serpent_121Balloons (CEOI11_bal)C++17
0 / 100
419 ms7320 KiB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
#include <stack>
#include <bitset>
typedef long long ll;
using namespace std;
// https://oj.uz/problem/view/CEOI11_bal

int main() {
    ll n; cin >> n;
    long double inflated[n]; // final inflated radii
    stack<pair<ll,ll>> s;
    for (int i = 0; i<n; i++) {
        ll x,r; cin >> x >> r;
        double constraint = r;
        while (!s.empty()) {
            double c = (x-s.top().first)*(x-s.top().first)/(double)(4*s.top().second);
            constraint = min(constraint,c);
            if (constraint > s.top().second) s.pop(); // we are sure that we can inflate to at least s.top().second
            else break; // now we are sure that a stronger constraint cannot be delivered
        }
        inflated[i] = constraint; s.push({x,constraint});
        cout << inflated[i] << '\n';
    }
}
#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...