結果

問題 No.1246 ANDORゲーム(max)
ユーザー 👑 rin204rin204
提出日時 2022-07-06 21:30:40
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 576 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 92,128 KB
最終ジャッジ日時 2023-08-24 21:06:08
合計ジャッジ時間 12,447 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,296 KB
testcase_01 AC 74 ms
71,376 KB
testcase_02 AC 73 ms
71,456 KB
testcase_03 AC 71 ms
71,348 KB
testcase_04 AC 71 ms
71,240 KB
testcase_05 AC 72 ms
71,300 KB
testcase_06 AC 71 ms
71,296 KB
testcase_07 AC 70 ms
71,216 KB
testcase_08 AC 72 ms
70,920 KB
testcase_09 AC 71 ms
71,408 KB
testcase_10 AC 72 ms
70,920 KB
testcase_11 AC 119 ms
77,232 KB
testcase_12 AC 98 ms
76,316 KB
testcase_13 AC 106 ms
76,836 KB
testcase_14 AC 122 ms
77,240 KB
testcase_15 AC 123 ms
77,456 KB
testcase_16 AC 549 ms
91,636 KB
testcase_17 AC 550 ms
91,724 KB
testcase_18 AC 558 ms
91,772 KB
testcase_19 AC 576 ms
91,812 KB
testcase_20 AC 565 ms
91,700 KB
testcase_21 AC 541 ms
91,700 KB
testcase_22 AC 549 ms
91,956 KB
testcase_23 AC 108 ms
92,128 KB
testcase_24 AC 478 ms
90,992 KB
testcase_25 AC 463 ms
90,992 KB
testcase_26 AC 500 ms
91,232 KB
testcase_27 AC 125 ms
90,972 KB
testcase_28 AC 467 ms
91,576 KB
testcase_29 AC 490 ms
91,596 KB
testcase_30 AC 460 ms
91,720 KB
testcase_31 AC 160 ms
89,404 KB
testcase_32 AC 159 ms
89,476 KB
testcase_33 AC 162 ms
89,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, t = map(int, input().split())
A = list(map(int, input().split()))

dp = {t:0}
for a in A:
    ndp = {}
    for k, v in dp.items():
        nk = k & a
        nv = v + abs(nk - k)
        ndp[nk] = max(ndp.get(nk, 0), nv)
        nk = k | a
        nv = v + abs(nk - k)
        ndp[nk] = max(ndp.get(nk, 0), nv)
    dp = ndp
print(max(dp.values()))
0