結果
問題 |
No.1246 ANDORゲーム(max)
|
ユーザー |
![]() |
提出日時 | 2020-08-04 18:59:50 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 471 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 170,848 KB |
最終ジャッジ日時 | 2024-09-14 19:47:55 |
合計ジャッジ時間 | 5,268 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 TLE * 1 -- * 17 |
ソースコード
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()))