답안 #1109346

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1109346 2024-11-06T13:26:49 Z Plot_Twist Balloons (CEOI11_bal) C++17
10 / 100
151 ms 8196 KB
#include<bits/stdc++.h>
#include<chrono>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
using namespace chrono;
#define ll long long
#define vl vector<long long>
#define endl '\n'
const int MOD = 1e9 + 7;
void inputv(vl &v) {for(int i = 0; i < (ll)v.size(); i++) cin>>v[i];}
void printv(vl v) {for(auto i : v) cout<<i<<" ";cout<<endl;}

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#include "template.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif

#define int long long

#define ld long double

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

int n;
vector<int>arr;
vector<int>maxRad;
vector<ld>ans;

int check(int x1, int x2, ld rad1, ld rad2) {
    ld temp = rad1/rad2;
    int high = 1e16;
    int ans = -1;
    int low = x2+1;
    while(low<=high) {
        int mid = (low+high)/2;
        ld t = (1 + (((ld)x2 - x1)/((ld)mid - x2)));
        t *= t;
        if(t<=temp) {
            ans = mid;
            low = mid+1;
        }
        else high = mid-1;
    }
    return ans;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
    ios::sync_with_stdio(false); cin.tie(NULL);
    int ts = 1;

    #ifndef ONLINE_JUDGE
    auto start = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
    #endif
    while(ts--) {
        cin>>n;
        arr = maxRad = vector<int>(n);
        for(int i = 0; i < n; i++) cin>>arr[i]>>maxRad[i];
        stack<pair<int,int>>st;
        ans = vector<ld>(n);
        ans[0] = maxRad[0];
        st.push({0,-1});
        for(int i = 1; i < n; i++) {
            while(st.top().second != -1 && st.top().second < arr[i]) st.pop();
            int prev = st.top().first;
            ld rad = min((ld)maxRad[i], ((ld)arr[i]-(ld)arr[prev])*((ld)arr[i]-(ld)arr[prev])/((ld)4.0*ans[prev]));
            ans[i] = rad;
            while(!st.empty() && ans[st.top().first] <= rad) st.pop();
            if(!st.empty()) {
                prev= st.top().first;
                int temp = check(arr[prev], arr[i], ans[prev], ans[i]);
                if(temp!=-1) st.push({i,temp});
            }
            else {
                st.push({i, -1});
            }
        }
        cout<<fixed<<setprecision(3);
        for(int i = 0; i < n; i++) cout<<ans[i]<<endl;

    }
    #ifndef ONLINE_JUDGE
    auto stop = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
    cerr << "Took " << stop - start << "ms" << endl;
    #endif
    
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB 5th numbers differ - expected: '17.1630000000', found: '99.0000000000', error = '81.8370000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 504 KB 3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 336 KB 114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 1104 KB 196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 2632 KB 13944th numbers differ - expected: '0.0000000000', found: '7.0000000000', error = '7.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 72 ms 4424 KB 7236th numbers differ - expected: '0.0070000000', found: '7.0000000000', error = '6.9930000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 82 ms 5008 KB 4645th numbers differ - expected: '0.0260000000', found: '8.0000000000', error = '7.9740000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 124 ms 6728 KB 1730th numbers differ - expected: '5.6890000000', found: '6.8060000000', error = '1.1170000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 151 ms 8196 KB 2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000'
2 Halted 0 ms 0 KB -