結果

問題 No.2009 Drunkers' Contest
ユーザー tamatotamato
提出日時 2022-07-15 22:12:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 142,272 KB
最終ジャッジ日時 2023-09-10 02:17:28
合計ジャッジ時間 11,937 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,596 KB
testcase_01 AC 72 ms
71,416 KB
testcase_02 AC 72 ms
71,492 KB
testcase_03 AC 74 ms
71,392 KB
testcase_04 AC 73 ms
71,076 KB
testcase_05 AC 74 ms
71,276 KB
testcase_06 AC 74 ms
71,740 KB
testcase_07 AC 74 ms
71,344 KB
testcase_08 AC 74 ms
71,464 KB
testcase_09 AC 73 ms
71,336 KB
testcase_10 AC 74 ms
71,492 KB
testcase_11 AC 73 ms
71,552 KB
testcase_12 AC 74 ms
71,520 KB
testcase_13 AC 73 ms
71,344 KB
testcase_14 AC 86 ms
76,708 KB
testcase_15 AC 86 ms
76,732 KB
testcase_16 AC 89 ms
76,888 KB
testcase_17 AC 88 ms
76,860 KB
testcase_18 AC 89 ms
76,940 KB
testcase_19 AC 91 ms
76,868 KB
testcase_20 AC 89 ms
76,996 KB
testcase_21 AC 89 ms
76,776 KB
testcase_22 AC 88 ms
76,900 KB
testcase_23 AC 92 ms
76,820 KB
testcase_24 AC 198 ms
131,636 KB
testcase_25 AC 188 ms
131,464 KB
testcase_26 AC 195 ms
131,592 KB
testcase_27 AC 194 ms
131,684 KB
testcase_28 AC 196 ms
131,544 KB
testcase_29 AC 196 ms
131,768 KB
testcase_30 AC 193 ms
131,272 KB
testcase_31 AC 190 ms
131,384 KB
testcase_32 AC 196 ms
131,580 KB
testcase_33 AC 196 ms
131,720 KB
testcase_34 AC 191 ms
130,388 KB
testcase_35 AC 194 ms
130,340 KB
testcase_36 AC 186 ms
130,484 KB
testcase_37 AC 183 ms
130,312 KB
testcase_38 AC 189 ms
130,412 KB
testcase_39 AC 190 ms
130,784 KB
testcase_40 AC 191 ms
130,540 KB
testcase_41 AC 186 ms
130,368 KB
testcase_42 AC 182 ms
130,184 KB
testcase_43 AC 190 ms
130,784 KB
testcase_44 AC 199 ms
134,596 KB
testcase_45 AC 173 ms
133,328 KB
testcase_46 AC 179 ms
142,272 KB
testcase_47 AC 179 ms
132,356 KB
testcase_48 AC 180 ms
132,392 KB
testcase_49 AC 170 ms
120,728 KB
testcase_50 AC 174 ms
124,184 KB
testcase_51 AC 180 ms
127,424 KB
testcase_52 AC 167 ms
118,152 KB
testcase_53 AC 174 ms
132,544 KB
testcase_54 AC 171 ms
131,148 KB
testcase_55 AC 171 ms
128,744 KB
testcase_56 AC 165 ms
128,412 KB
testcase_57 AC 173 ms
132,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    from math import sqrt
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    st = [(1.0, 0, 0, 0)]
    for a, b in zip(A, B):
        x_new = sqrt(a / b)
        if x_new >= st[-1][0]:
            st.append((x_new, a, b, a / x_new + b * x_new))
        else:
            sa = a
            sb = b
            while st:
                x_old, aa, bb, c = st.pop()
                sa += aa
                sb += bb
                x_new = sqrt(sa / sb)
                if not st:
                    if x_new <= 1:
                        st.append((1.0, sa, sb, sa + sb))
                    else:
                        st.append((x_new, sa, sb, sa / x_new + sb * x_new))
                    break
                else:
                    if x_new >= st[-1][0]:
                        st.append((x_new, sa, sb, sa / x_new + sb * x_new))
                        break
    ans = 0
    for _, _, _, y in st:
        ans += y
    print(ans)


if __name__ == '__main__':
    main()
0