結果
問題 |
No.1246 ANDORゲーム(max)
|
ユーザー |
![]() |
提出日時 | 2020-08-04 19:00:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 835 ms / 2,000 ms |
コード長 | 471 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,240 KB |
実行使用メモリ | 204,816 KB |
最終ジャッジ日時 | 2024-09-14 19:48:12 |
合計ジャッジ時間 | 13,156 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
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()))