結果

問題 No.2009 Drunkers' Contest
ユーザー 259_Momone
提出日時 2022-07-15 21:36:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 871 bytes
コンパイル時間 4,428 ms
コンパイル使用メモリ 253,388 KB
最終ジャッジ日時 2025-01-30 07:32:59
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<unsigned long, unsigned long>> problems(N);
    for(auto&& [a, _] : problems)cin >> a;
    for(auto&& [_, b] : problems)cin >> b;
    reverse(begin(problems), end(problems));
    vector<pair<unsigned long, unsigned long>> stack;
    while(!empty(problems)){
        auto [a, b]{problems.back()};
        problems.pop_back();
        while(!empty(stack) && stack.back().first * b >= stack.back().second * a){
            a += stack.back().first;
            b += stack.back().second;
            stack.pop_back();
        }
        stack.emplace_back(a, b);
    }
    long double ans{};
    for(const auto& [a, b] : stack)ans += a < b ? a + b : sqrt(static_cast<long double>(4 * a * b));
    cout << fixed << setprecision(30) << ans << endl;
    return 0;
}
0