結果

問題 No.1246 ANDORゲーム(max)
ユーザー 👑 tute7627tute7627
提出日時 2020-08-04 19:00:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 850 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 205,264 KB
最終ジャッジ日時 2023-10-12 21:30:27
合計ジャッジ時間 14,984 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,232 KB
testcase_01 AC 76 ms
71,128 KB
testcase_02 AC 74 ms
71,224 KB
testcase_03 AC 74 ms
71,216 KB
testcase_04 AC 75 ms
71,368 KB
testcase_05 AC 75 ms
71,236 KB
testcase_06 AC 73 ms
71,368 KB
testcase_07 AC 72 ms
71,132 KB
testcase_08 AC 73 ms
71,016 KB
testcase_09 AC 74 ms
71,364 KB
testcase_10 AC 73 ms
70,980 KB
testcase_11 AC 110 ms
79,420 KB
testcase_12 AC 90 ms
76,448 KB
testcase_13 AC 93 ms
76,608 KB
testcase_14 AC 115 ms
79,300 KB
testcase_15 AC 116 ms
79,280 KB
testcase_16 AC 841 ms
201,012 KB
testcase_17 AC 839 ms
200,980 KB
testcase_18 AC 842 ms
201,252 KB
testcase_19 AC 841 ms
200,876 KB
testcase_20 AC 844 ms
200,948 KB
testcase_21 AC 846 ms
200,972 KB
testcase_22 AC 850 ms
201,132 KB
testcase_23 AC 139 ms
100,956 KB
testcase_24 AC 818 ms
205,192 KB
testcase_25 AC 763 ms
204,944 KB
testcase_26 AC 766 ms
205,264 KB
testcase_27 AC 169 ms
107,968 KB
testcase_28 AC 724 ms
197,184 KB
testcase_29 AC 740 ms
204,572 KB
testcase_30 AC 726 ms
197,196 KB
testcase_31 AC 190 ms
104,748 KB
testcase_32 AC 191 ms
104,636 KB
testcase_33 AC 195 ms
104,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,t = map(int,input().split())
a = list(map(int,input().split()))
dp = []
for i in range(n+1):
    dp.append({})
dp[0][t] = 0
for i in range(n):
    for now, score in dp[i].items():
        for j in range(2):
            nxt = now & a[i]
            if j == 1:
                nxt = now | a[i]
            nxtscore = score + abs(now - nxt)
            if not (nxt in dp[i+1]) or dp[i+1][nxt] < nxtscore:
                dp[i+1][nxt] = nxtscore
print(max(dp[n].values()))
0