結果

問題 No.1246 ANDORゲーム(max)
コンテスト
ユーザー 👑 tute7627
提出日時 2020-08-04 18:59:50
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 471 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 303 ms
コンパイル使用メモリ 21,536 KB
実行使用メモリ 246,860 KB
最終ジャッジ日時 2026-08-27 09:54:33
合計ジャッジ時間 6,986 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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