結果

問題 No.1246 ANDORゲーム(max)
ユーザー 👑 tamatotamato
提出日時 2020-10-02 23:14:22
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 751 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 2,097 ms
コンパイル使用メモリ 87,484 KB
実行使用メモリ 91,632 KB
最終ジャッジ日時 2023-09-24 23:16:34
合計ジャッジ時間 12,395 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,556 KB
testcase_01 AC 67 ms
71,796 KB
testcase_02 AC 67 ms
71,588 KB
testcase_03 AC 67 ms
71,736 KB
testcase_04 AC 66 ms
71,656 KB
testcase_05 AC 67 ms
71,836 KB
testcase_06 AC 68 ms
71,712 KB
testcase_07 AC 67 ms
71,816 KB
testcase_08 AC 66 ms
71,868 KB
testcase_09 AC 66 ms
71,764 KB
testcase_10 AC 66 ms
71,752 KB
testcase_11 AC 109 ms
77,568 KB
testcase_12 AC 89 ms
76,472 KB
testcase_13 AC 95 ms
76,604 KB
testcase_14 AC 116 ms
77,744 KB
testcase_15 AC 113 ms
77,720 KB
testcase_16 AC 727 ms
91,088 KB
testcase_17 AC 751 ms
91,532 KB
testcase_18 AC 720 ms
91,292 KB
testcase_19 AC 735 ms
91,172 KB
testcase_20 AC 746 ms
91,152 KB
testcase_21 AC 697 ms
91,232 KB
testcase_22 AC 693 ms
91,260 KB
testcase_23 AC 102 ms
91,632 KB
testcase_24 AC 579 ms
90,732 KB
testcase_25 AC 555 ms
90,832 KB
testcase_26 AC 611 ms
90,732 KB
testcase_27 AC 118 ms
90,668 KB
testcase_28 AC 545 ms
91,292 KB
testcase_29 AC 595 ms
91,240 KB
testcase_30 AC 548 ms
91,288 KB
testcase_31 AC 149 ms
90,096 KB
testcase_32 AC 147 ms
90,044 KB
testcase_33 AC 151 ms
90,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, T = map(int, input().split())
    A = list(map(int, input().split()))

    X = {T: 0}
    for a in A:
        X_new = {}
        for x in X:
            x_and = x & a
            x_or = x | a
            if x_and not in X_new:
                X_new[x_and] = X[x] + x - x_and
            else:
                X_new[x_and] = max(X_new[x_and], X[x] + x - x_and)
            if x_or not in X_new:
                X_new[x_or] = X[x] + x_or - x
            else:
                X_new[x_or] = max(X_new[x_or], X[x] + x_or - x)
        X = X_new
        #print(X)
    ans = 0
    for x in X:
        ans = max(ans, X[x])
    print(ans)


if __name__ == '__main__':
    main()
0