結果

問題 No.1682 Unfair Game
ユーザー shotoyoo
提出日時 2021-09-24 01:04:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 52,608 KB
最終ジャッジ日時 2024-07-05 09:37:27
合計ジャッジ時間 2,177 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n = int(input())
p = list(map(int, input().split()))
M = 10**9+7
inv2 = pow(2, M-2, M)
dp = [1,0,0] # (0.5未満, 0.5, 0.5以上)
for v in p:
    ndp = dp[:]
    if v<50:
        for i in range(3):
            ndp[i] += dp[i]
            ndp[i] %= M
    elif v>50:
        for i in range(3):
            ndp[2-i] += dp[i]
            ndp[2-i] %= M
    else:
        ndp[1] += sum(dp)
        ndp[1] %= M
    dp = ndp
ans = dp[2]
print(ans%M)
0