結果

問題 No.2009 Drunkers' Contest
コンテスト
ユーザー 259_Momone
提出日時 2022-07-15 21:46:58
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 1,022 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,552 ms
コンパイル使用メモリ 533,252 KB
実行使用メモリ 32,444 KB
最終ジャッジ日時 2026-06-26 15:36:37
合計ジャッジ時間 10,231 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 54
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from main.cpp:2:
In member function 'void boost::multiprecision::backends::cpp_int_base<MinBits, MaxBits, boost::multiprecision::signed_magnitude, Checked, Allocator, false>::resize(std::size_t, std::size_t) [with long unsigned int MinBits = 0; long unsigned int MaxBits = 18446744073709551615; boost::multiprecision::cpp_int_check_type Checked = boost::multiprecision::unchecked; Allocator = std::allocator<long long unsigned int>]',
    inlined from 'constexpr void boost::multiprecision::backends::add_unsigned(CppInt1&, const CppInt2&, const boost::multiprecision::limb_type&) [with CppInt1 = cpp_int_backend<>; CppInt2 = cpp_int_backend<>]' at /usr/local/include/boost/multiprecision/cpp_int/add.hpp:50:20,
    inlined from 'constexpr typename std::enable_if<(! boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >::value)>::type boost::multiprecision::backends::eval_add(cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>&, const boost::multiprecision::limb_type&) [with long unsigned int MinBits1 = 0; long unsigned int MaxBits1 = 0; boost::multiprecision::cpp_integer_type SignType1 = boost::multiprecision::signed_magnitude; boost::multiprecision::cpp_int_check_type Checked1 = boost::multiprecision::unchecked; Allocator1 = std::allocator<long long unsigned int>]' at /usr/local/include/boost/multiprecision/cpp_int/add.hpp:141:19,
    inlined from 'void boost::multiprecision::backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>::do_assign_string(const char*, const std::integral_constant<bool, false>&) [with long unsigned int MinBits = 0; long unsigned int MaxBits = 0; boost::multiprecision::cpp_integer_type SignType = boost::multiprecision::signed_magnitude; boost::multiprecision::cpp_int_check_type Checked = boost::multiprecision::unchecked; Allocator = std::allocator<long long unsigned int>]' at /usr/local/include/boost/multipre

ソースコード

diff #
raw source code

#include <bits/extc++.h>
#include <boost/multiprecision/cpp_int.hpp>

int main(){
    using namespace std;
    using bigint = boost::multiprecision::cpp_int;
    unsigned long N;
    cin >> N;
    vector<pair<bigint, bigint>> problems(N);
    for(auto&& [a, _] : problems)cin >> a;
    for(auto&& [_, b] : problems)cin >> b;
    reverse(begin(problems), end(problems));
    vector<pair<bigint, bigint>> 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 ? static_cast<long double>(a) + static_cast<long double>(b) : 2 * sqrt(static_cast<long double>(a)) * sqrt(static_cast<long double>(b));
    cout << fixed << setprecision(30) << ans << endl;
    return 0;
}
0