답안 #548929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548929 2022-04-14T18:49:16 Z erto Balloons (CEOI11_bal) C++17
0 / 100
309 ms 1512 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-4){
        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 << 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(h, ans2);
                    if(t2 >= t)break;
                    s.pop();
                }
                cout << t << "\n";
                s.push({g, t});
            }
            else{
                cout << 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();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 8th numbers differ - expected: '8.7410000000', found: '9.0909600000', error = '0.3499600000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 1st numbers differ - expected: '247294217.0000000000', found: '247294000.0000000000', error = '217.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 13th numbers differ - expected: '2.3960000000', found: '2.4500400000', error = '0.0540400000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 340 KB 3rd numbers differ - expected: '121.0000000000', found: '121.0020000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 356 KB 35th numbers differ - expected: '174.0000000000', found: '174.0020000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 79 ms 648 KB 250th numbers differ - expected: '15134.0000000000', found: '18307.0000000000', error = '3173.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 172 ms 828 KB 162nd numbers differ - expected: '7765.0000000000', found: '14571.0000000000', error = '6806.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 206 ms 1012 KB 510th numbers differ - expected: '4505.0010000000', found: '13465.0000000000', error = '8959.9990000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 254 ms 1100 KB 161st numbers differ - expected: '1703.0000000000', found: '4036.0000000000', error = '2333.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 309 ms 1512 KB 248th numbers differ - expected: '2694.0020000000', found: '8658.0000000000', error = '5963.9980000000'
2 Halted 0 ms 0 KB -