結果

問題 No.1904 Never giving up!
ユーザー 👑 rin204rin204
提出日時 2022-04-15 21:26:16
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 455 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 86,676 KB
実行使用メモリ 93,260 KB
最終ジャッジ日時 2023-08-26 07:29:09
合計ジャッジ時間 3,418 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,292 KB
testcase_01 AC 66 ms
71,140 KB
testcase_02 AC 455 ms
93,124 KB
testcase_03 AC 69 ms
71,340 KB
testcase_04 AC 190 ms
85,072 KB
testcase_05 AC 437 ms
93,224 KB
testcase_06 AC 436 ms
93,260 KB
testcase_07 AC 64 ms
71,300 KB
testcase_08 AC 70 ms
76,340 KB
testcase_09 AC 72 ms
76,448 KB
testcase_10 AC 93 ms
77,440 KB
testcase_11 AC 428 ms
93,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
cnt = 0
dp = [0] * (1 << n)
max_ = [0] * (1 << n)
dp[0] = 1
for bit in range(1, 1 << n):
    for i in range(n):
        if bit >> i & 1:
            bbit = bit ^ (1 << i)
            if A[i] >= max_[bbit]:
                max_[bit] = A[i]
                dp[bit] += dp[bbit]

x = dp[-1]
ans = 1
for i in range(1, n + 1):
    ans *= i
print(ans // x)
0