結果

問題 No.2009 Drunkers' Contest
ユーザー 259_Momone259_Momone
提出日時 2022-07-15 21:43:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,040 bytes
コンパイル時間 4,888 ms
コンパイル使用メモリ 262,372 KB
実行使用メモリ 11,616 KB
最終ジャッジ日時 2023-09-10 01:08:30
合計ジャッジ時間 11,529 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,384 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 4 ms
4,384 KB
testcase_18 AC 4 ms
4,384 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 4 ms
4,384 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 135 ms
6,240 KB
testcase_35 AC 136 ms
6,108 KB
testcase_36 AC 136 ms
6,124 KB
testcase_37 AC 136 ms
6,140 KB
testcase_38 AC 135 ms
6,116 KB
testcase_39 AC 136 ms
6,152 KB
testcase_40 AC 135 ms
6,160 KB
testcase_41 AC 135 ms
6,156 KB
testcase_42 AC 137 ms
6,300 KB
testcase_43 AC 135 ms
6,200 KB
testcase_44 AC 159 ms
6,052 KB
testcase_45 AC 158 ms
6,204 KB
testcase_46 AC 110 ms
6,232 KB
testcase_47 AC 90 ms
11,616 KB
testcase_48 AC 89 ms
11,480 KB
testcase_49 AC 90 ms
11,352 KB
testcase_50 AC 89 ms
10,716 KB
testcase_51 AC 90 ms
10,452 KB
testcase_52 AC 89 ms
8,148 KB
testcase_53 AC 111 ms
8,340 KB
testcase_54 AC 109 ms
8,376 KB
testcase_55 AC 106 ms
6,604 KB
testcase_56 AC 107 ms
6,540 KB
testcase_57 AC 107 ms
8,352 KB
権限があれば一括ダウンロードができます

ソースコード

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 / stack.back().second > a / b || (stack.back().first / stack.back().second == a / b && (stack.back().first % stack.back().second) * b / stack.back().second >= a % b))){
            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 : 2 * sqrt(static_cast<long double>(a)) * sqrt(static_cast<long double>(b));
    cout << fixed << setprecision(30) << ans << endl;
    return 0;
}
0