結果

問題 No.412 花火大会
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-08 20:29:06
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 11,800 KB
実行使用メモリ 10,232 KB
最終ジャッジ日時 2023-10-18 22:07:17
合計ジャッジ時間 2,496 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,228 KB
testcase_01 AC 30 ms
10,228 KB
testcase_02 AC 31 ms
10,228 KB
testcase_03 AC 30 ms
10,228 KB
testcase_04 AC 30 ms
10,228 KB
testcase_05 AC 31 ms
10,228 KB
testcase_06 AC 30 ms
10,228 KB
testcase_07 AC 31 ms
10,228 KB
testcase_08 AC 31 ms
10,228 KB
testcase_09 AC 31 ms
10,228 KB
testcase_10 AC 31 ms
10,228 KB
testcase_11 AC 31 ms
10,228 KB
testcase_12 AC 30 ms
10,228 KB
testcase_13 AC 30 ms
10,228 KB
testcase_14 AC 31 ms
10,228 KB
testcase_15 AC 30 ms
10,228 KB
testcase_16 AC 31 ms
10,228 KB
testcase_17 AC 30 ms
10,228 KB
testcase_18 AC 31 ms
10,228 KB
testcase_19 AC 31 ms
10,228 KB
testcase_20 AC 30 ms
10,228 KB
testcase_21 AC 30 ms
10,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
bcd = sorted(map(int, input().split()))
n = int(input())
E = sorted(map(int, input().split()))

dp = [0] * 8
dp[0] = 1
for e in E:
    newDP = dp[:]
    b = bisect.bisect_right(bcd, e)
    if b == 0:
        newDP = [x * 2 for x in dp]
    elif b == 1:
        for bit in range(8):
            if bit & 1:
                newDP[bit] += dp[bit]
                newDP[bit] += dp[bit ^ 1]
    elif b == 2:
        newDP[2] += dp[0]
        newDP[3] += dp[1] + dp[2] + dp[3]
        newDP[6] += dp[4]
        newDP[7] += dp[5] + dp[6] + dp[7]
    else:
        newDP[4] += dp[0]
        newDP[5] += dp[1]
        newDP[6] += dp[2] + dp[4]
        newDP[7] += dp[3] + dp[5] + dp[6] + dp[7]
    dp = newDP

print(dp[7])
0