Submission #548941

# Submission time Handle Problem Language Result Execution time Memory
548941 2022-04-14T19:30:57 Z erto Balloons (CEOI11_bal) C++17
10 / 100
343 ms 2476 KB
#include <bits/stdc++.h>
typedef long long int ll;
#define INF (1e9 + 7)
#define INF2 (998244353)
#define N (ll)1e6+1005
using namespace std;

int n;
long double g, t, h, t1, t2, t3;
long double ans2;
stack<pair<ll, ll>> s;

long double f(long double x, long double y){
    long double t1 = y * y, l=0, r=y, mid, ans = 1e9;
    while(r - l >= 1e-6){
        mid = (r + l) / 2;
        if(t1 + (x - mid) * (x - mid) <= (mid + x) * (mid + x)){
            ans = mid;
            r = mid;
        }
        else{
            l = mid;
        }
    }
    return ans;
}

void solve(){
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> g >> h;
        if(s.empty()){
            s.push({g, h});
            cout <<fixed << setprecision(6)<< h << "\n";
        }
        else{
            tie(t1, t2) = s.top();
            ans2 = f(t2, (g - t1));
            t = min(h, ans2);
            if(t2 <= t){
                s.pop();
                while(!s.empty()){
                    tie(t1, t2) = s.top();
                    ans2 = f(t2, (g - t1));
                    t = min(t, min(h, ans2));
                    if(t2 > t)break;
                    s.pop();
                }
                cout << fixed << setprecision(6)<< t << "\n";
                s.push({g, t});
            }
            else{
                cout <<fixed << setprecision(6)<< t<<'\n';
                s.push({g, t});
            }
        }
    }
}   

int main(){ 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    //cin>>T;
    while (T--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 8th numbers differ - expected: '8.7410000000', found: '9.0909090000', error = '0.3499090000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB 13th numbers differ - expected: '2.3960000000', found: '2.4500000000', error = '0.0540000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 340 KB 3rd numbers differ - expected: '121.0000000000', found: '121.0020500000', error = '0.0020500000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 440 KB 71st numbers differ - expected: '136.0000000000', found: '136.0018250000', error = '0.0018250000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 972 KB 254th numbers differ - expected: '15129.9990000000', found: '15130.0013400000', error = '0.0023400000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 198 ms 1600 KB 286th numbers differ - expected: '7633.9990000000', found: '7634.0008200000', error = '0.0018200000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 1740 KB 512th numbers differ - expected: '4502.9990000000', found: '4503.0045060000', error = '0.0055060000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 291 ms 2280 KB 165th numbers differ - expected: '1698.9980000000', found: '1699.0001470000', error = '0.0021470000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 343 ms 2476 KB 249th numbers differ - expected: '2683.0090000000', found: '2683.0112290000', error = '0.0022290000'
2 Halted 0 ms 0 KB -