답안 #563314

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563314 2022-05-16T20:57:59 Z ljuba Balloons (CEOI11_bal) C++17
100 / 100
161 ms 12144 KB
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef vector<int> vi;
typedef vector<ll> vll;
 
typedef vector<vi> vvi;
typedef vector<vll> vvll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
typedef vector<pii> vpii;
typedef vector<pll> vpll;
 
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
 
template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}
 
namespace debug {
    void __print(int x) {cerr << x;}
    void __print(long long x) {cerr << x;}
    void __print(double x) {cerr << x;}
    void __print(long double x) {cerr << x;}
    void __print(char x) {cerr << '\'' << x << '\'';}
    void __print(const string &x) {cerr << '\"' << x << '\"';}
    void __print(const char *x) {cerr << '\"' << x << '\"';}
    void __print(bool x) {cerr << (x ? "true" : "false");}
 
    template<typename T, typename V>
    void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
    template<typename T>
    void __print(const T &x) {int f = 0; cerr << '{'; for(auto z : x) cerr << (f++ ? "," : ""), __print(z); cerr << "}";}
    void _print() {cerr << "]\n";}
    template <typename T, typename... V>
    void _print(T t, V... v) {__print(t); if(sizeof...(v)) cerr << ", "; _print(v...);}
 
#ifdef ljuba
#define dbg(x...) cerr << "\e[91m" << "LINE(" << __LINE__ << ") -> " << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
}
 
using namespace debug;
 
const char nl = '\n';
 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
 
/*
“If you win, you live. If you lose, you die. If you don’t fight, you can’t win!”
― Eren Yaeger
*/

void solve() {
    int n;
    cin >> n;

    vpll v(n);
    for(auto &z : v) cin >> z.fi >> z.se;

    stack<pair<ll, ld>> st;

    vector<ld> ans(n);

    for(int i = 0; i < n; ++i) {
        //rb = ((xb - xa) ^ 2) / 4 * ra
        ld stavi = v[i].second;
        while(!st.empty()) {
            auto tren = st.top();
            ld treba = ld((v[i].first - tren.first) * (v[i].first - tren.first));
            treba /= ld(4 * tren.se);

            ckmin(stavi, treba);
            if(stavi >= tren.se) {
                st.pop();
            } else {
                break;
            }
        }

        ans[i] = stavi;
        st.push({v[i].first, ans[i]});
    }

    for(auto z : ans) {
        cout << fixed << setprecision(5) << z << nl;
    }
}
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    int testCases = 1;
    //cin >> testCases;
    while(testCases--)
        solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB 505 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB 2000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1160 KB 20000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 2668 KB 50000 numbers
2 Correct 36 ms 3300 KB 49912 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 4764 KB 100000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 5448 KB 115362 numbers
2 Correct 79 ms 7380 KB 119971 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 6988 KB 154271 numbers
2 Correct 131 ms 12112 KB 200000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 161 ms 8644 KB 200000 numbers
2 Correct 129 ms 12144 KB 199945 numbers