結果

問題 No.1083 余りの余り
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-19 22:37:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 492 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 194,860 KB
最終ジャッジ日時 2023-09-16 14:52:59
合計ジャッジ時間 12,677 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,128 KB
testcase_01 AC 73 ms
71,480 KB
testcase_02 AC 88 ms
76,476 KB
testcase_03 AC 73 ms
71,572 KB
testcase_04 AC 88 ms
76,664 KB
testcase_05 AC 1,318 ms
133,948 KB
testcase_06 AC 71 ms
71,248 KB
testcase_07 AC 89 ms
76,540 KB
testcase_08 AC 89 ms
76,472 KB
testcase_09 AC 82 ms
76,592 KB
testcase_10 AC 87 ms
76,244 KB
testcase_11 AC 89 ms
76,800 KB
testcase_12 AC 84 ms
76,640 KB
testcase_13 AC 81 ms
76,500 KB
testcase_14 AC 75 ms
71,328 KB
testcase_15 AC 72 ms
71,200 KB
testcase_16 AC 72 ms
71,360 KB
testcase_17 AC 73 ms
71,408 KB
testcase_18 AC 2,794 ms
194,860 KB
testcase_19 AC 1,311 ms
133,648 KB
testcase_20 AC 97 ms
76,700 KB
testcase_21 AC 193 ms
83,772 KB
testcase_22 AC 72 ms
71,252 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [[0] * N for _ in range(1 << N)]
for i, a in enumerate(A):
    dp[1 << i][i] = K % a

for bit in range(1 << N):
    for i in range(N):
        if (bit >> i) & 1:
            for j, a in enumerate(A):
                if ~(bit >> j) & 1:
                    bit_next = bit | (1 << j)
                    dp[bit_next][j] = max(dp[bit_next][j], dp[bit][i] % a)

ans = max(dp[(1 << N) - 1][i] for i in range(N))
print(ans)
0