結果

問題 No.2071 Shift and OR
ユーザー lloyzlloyz
提出日時 2022-09-16 23:30:02
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 312 ms / 2,000 ms
コード長 520 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 84,952 KB
最終ジャッジ日時 2023-08-23 16:46:38
合計ジャッジ時間 8,191 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
77,712 KB
testcase_01 AC 102 ms
78,360 KB
testcase_02 AC 117 ms
79,256 KB
testcase_03 AC 160 ms
80,340 KB
testcase_04 AC 132 ms
79,632 KB
testcase_05 AC 214 ms
81,836 KB
testcase_06 AC 143 ms
79,900 KB
testcase_07 AC 120 ms
79,536 KB
testcase_08 AC 130 ms
79,672 KB
testcase_09 AC 135 ms
79,712 KB
testcase_10 AC 137 ms
79,752 KB
testcase_11 AC 221 ms
82,344 KB
testcase_12 AC 224 ms
82,256 KB
testcase_13 AC 204 ms
81,836 KB
testcase_14 AC 89 ms
76,852 KB
testcase_15 AC 181 ms
80,768 KB
testcase_16 AC 177 ms
80,996 KB
testcase_17 AC 229 ms
82,464 KB
testcase_18 AC 102 ms
78,188 KB
testcase_19 AC 260 ms
82,844 KB
testcase_20 AC 257 ms
82,912 KB
testcase_21 AC 312 ms
84,952 KB
testcase_22 AC 276 ms
83,520 KB
testcase_23 AC 76 ms
71,416 KB
testcase_24 AC 74 ms
71,276 KB
testcase_25 AC 75 ms
71,308 KB
testcase_26 AC 75 ms
71,300 KB
testcase_27 AC 74 ms
71,308 KB
testcase_28 AC 77 ms
71,368 KB
testcase_29 AC 77 ms
71,220 KB
testcase_30 AC 160 ms
80,416 KB
testcase_31 AC 137 ms
80,288 KB
testcase_32 AC 141 ms
80,288 KB
testcase_33 AC 143 ms
80,100 KB
testcase_34 AC 148 ms
80,372 KB
testcase_35 AC 147 ms
80,152 KB
testcase_36 AC 156 ms
80,316 KB
testcase_37 AC 143 ms
80,100 KB
testcase_38 AC 139 ms
80,268 KB
testcase_39 AC 141 ms
80,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n >= 16:
    print((1 << 16) - 1)
    exit()

A = list(map(int, input().split()))
DP = [[False for _ in range(1 << 16)] for _ in range(n + 1)]
header = 1 << 15
for i in range(n + 1):
    DP[i][0] = True
for i in range(n):
    a = A[i]
    for j in range(16):
        for k in range(1 << 16):
            if DP[i][k]:
                DP[i + 1][k | a] |= DP[i][k]
        a, r = divmod(a, 2)
        a |= header * r
for i in range((1 << 16) - 1, 0, -1):
    if DP[n][i]:
        print(i)
        break
0