結果

問題 No.2009 Drunkers' Contest
ユーザー momoyuumomoyuu
提出日時 2023-09-24 14:38:39
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,301 bytes
コンパイル時間 2,764 ms
コンパイル使用メモリ 250,496 KB
実行使用メモリ 12,192 KB
最終ジャッジ日時 2023-09-24 14:38:52
合計ジャッジ時間 12,022 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,384 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 98 ms
6,344 KB
testcase_25 AC 99 ms
6,176 KB
testcase_26 AC 98 ms
6,184 KB
testcase_27 AC 97 ms
6,168 KB
testcase_28 AC 98 ms
6,148 KB
testcase_29 AC 98 ms
6,212 KB
testcase_30 AC 97 ms
6,116 KB
testcase_31 AC 97 ms
6,120 KB
testcase_32 AC 98 ms
6,164 KB
testcase_33 AC 97 ms
6,164 KB
testcase_34 AC 91 ms
6,112 KB
testcase_35 AC 92 ms
6,148 KB
testcase_36 AC 93 ms
6,124 KB
testcase_37 AC 92 ms
6,104 KB
testcase_38 AC 92 ms
6,096 KB
testcase_39 AC 92 ms
6,164 KB
testcase_40 AC 92 ms
6,192 KB
testcase_41 AC 91 ms
6,144 KB
testcase_42 AC 92 ms
6,144 KB
testcase_43 AC 91 ms
6,096 KB
testcase_44 AC 101 ms
6,112 KB
testcase_45 AC 98 ms
6,120 KB
testcase_46 AC 81 ms
6,200 KB
testcase_47 AC 77 ms
11,100 KB
testcase_48 AC 77 ms
10,748 KB
testcase_49 AC 76 ms
10,860 KB
testcase_50 AC 79 ms
11,372 KB
testcase_51 AC 76 ms
12,192 KB
testcase_52 AC 75 ms
8,344 KB
testcase_53 AC 87 ms
8,284 KB
testcase_54 AC 84 ms
8,372 KB
testcase_55 AC 80 ms
6,724 KB
testcase_56 AC 81 ms
6,660 KB
testcase_57 AC 82 ms
8,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;


ll dp[2][310][310][310];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    vector<double> a(n),b(n);
    for(int i = 0;i<n;i++) cin>>a[i];
    for(int i = 0;i<n;i++) cin>>b[i];
    vector<pair<double,double>> st;
    for(int i = 0;i<n;i++){
        if(st.empty()){
            st.push_back(make_pair(a[i],b[i]));
            continue;
        }
        st.push_back(make_pair(a[i],b[i]));
        while(st.size()>=2){
            auto now = st.back();
            st.pop_back();
            auto nxt = st.back();
            st.pop_back();
            if(now.first/now.second <= nxt.first/nxt.second){
                now.first += nxt.first;
                now.second += nxt.second;
                st.push_back(now);
            }else{
                st.push_back(nxt);
                st.push_back(now);
                break;
            }
        }
    }
    double ans = 0;
    for(int i = 0;i<st.size();i++){
        auto now = st[i];
        double use = now.first / now.second;
        if(use<1) use = 0;
        else{
            use = sqrt(use) - 1;
        }
        ans += now.first /(1+use)  + now.second * (1+use);
    }
    cout<<setprecision(30)<<fixed<<ans<<endl;

}

0