結果

問題 No.1590 Random Shopping
ユーザー 👑 tamatotamato
提出日時 2021-07-08 23:54:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,636 ms / 5,000 ms
コード長 1,038 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 87,744 KB
実行使用メモリ 199,860 KB
最終ジャッジ日時 2023-09-14 05:44:52
合計ジャッジ時間 14,468 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,768 KB
testcase_01 AC 69 ms
71,956 KB
testcase_02 AC 68 ms
71,612 KB
testcase_03 AC 69 ms
71,692 KB
testcase_04 AC 70 ms
71,756 KB
testcase_05 AC 69 ms
71,928 KB
testcase_06 AC 69 ms
71,792 KB
testcase_07 AC 75 ms
76,144 KB
testcase_08 AC 84 ms
76,744 KB
testcase_09 AC 85 ms
77,148 KB
testcase_10 AC 90 ms
76,980 KB
testcase_11 AC 109 ms
77,772 KB
testcase_12 AC 183 ms
78,512 KB
testcase_13 AC 467 ms
89,476 KB
testcase_14 AC 1,405 ms
162,972 KB
testcase_15 AC 1,324 ms
174,236 KB
testcase_16 AC 1,391 ms
161,956 KB
testcase_17 AC 1,323 ms
178,036 KB
testcase_18 AC 69 ms
71,700 KB
testcase_19 AC 1,261 ms
148,396 KB
testcase_20 AC 75 ms
71,972 KB
testcase_21 AC 1,204 ms
151,480 KB
testcase_22 AC 74 ms
71,936 KB
testcase_23 AC 1,636 ms
199,860 KB
testcase_24 AC 1,487 ms
174,328 KB
testcase_25 AC 74 ms
71,924 KB
testcase_26 AC 70 ms
71,764 KB
testcase_27 AC 72 ms
71,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


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

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

    ans = 0
    for i0, a0 in enumerate(A):
        dp = [[0.] * (i+1) for i in range(N+1)]
        dp[0][0] = 1.
        for i, a in enumerate(A):
            r = R[i]
            for j in range(i+1):
                if a > a0 or (a == a0 and i >= i0):
                    dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 0.5)
                    if j:
                        dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j] * 0.5)
                    else:
                        if i >= i0:
                            ans += r * a0 * dp[i][j] * 0.5
                        else:
                            dp[i+1][j] = dp[i+1][j] + dp[i][j] * 0.5
                else:
                    dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 0.5)
                    dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j] * 0.5)
    print(ans)


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