結果

問題 No.1083 余りの余り
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-19 22:38:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 600 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 331,284 KB
最終ジャッジ日時 2023-09-16 14:54:05
合計ジャッジ時間 12,780 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,432 KB
testcase_01 AC 72 ms
71,376 KB
testcase_02 AC 88 ms
76,104 KB
testcase_03 AC 75 ms
71,008 KB
testcase_04 AC 86 ms
76,336 KB
testcase_05 AC 1,352 ms
133,488 KB
testcase_06 AC 71 ms
71,156 KB
testcase_07 AC 88 ms
76,448 KB
testcase_08 AC 86 ms
76,184 KB
testcase_09 AC 80 ms
76,292 KB
testcase_10 AC 85 ms
76,180 KB
testcase_11 AC 88 ms
76,408 KB
testcase_12 AC 82 ms
76,340 KB
testcase_13 AC 81 ms
76,324 KB
testcase_14 AC 70 ms
71,388 KB
testcase_15 AC 72 ms
71,240 KB
testcase_16 AC 71 ms
71,096 KB
testcase_17 AC 71 ms
71,364 KB
testcase_18 AC 2,901 ms
194,448 KB
testcase_19 AC 1,361 ms
133,596 KB
testcase_20 AC 97 ms
76,432 KB
testcase_21 AC 195 ms
83,296 KB
testcase_22 AC 74 ms
71,008 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 #

def main():
    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)


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