結果

問題 No.2071 Shift and OR
ユーザー shotoyooshotoyoo
提出日時 2022-09-16 21:29:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 107,676 KB
最終ジャッジ日時 2023-08-23 14:27:29
合計ジャッジ時間 7,390 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
78,636 KB
testcase_01 AC 107 ms
79,128 KB
testcase_02 AC 112 ms
80,112 KB
testcase_03 AC 139 ms
81,016 KB
testcase_04 AC 123 ms
80,508 KB
testcase_05 AC 169 ms
82,760 KB
testcase_06 AC 129 ms
80,492 KB
testcase_07 AC 117 ms
79,908 KB
testcase_08 AC 127 ms
80,480 KB
testcase_09 AC 123 ms
80,488 KB
testcase_10 AC 127 ms
80,652 KB
testcase_11 AC 171 ms
83,016 KB
testcase_12 AC 177 ms
83,304 KB
testcase_13 AC 163 ms
82,516 KB
testcase_14 AC 99 ms
77,676 KB
testcase_15 AC 151 ms
81,532 KB
testcase_16 AC 150 ms
81,364 KB
testcase_17 AC 177 ms
83,056 KB
testcase_18 AC 105 ms
79,056 KB
testcase_19 AC 192 ms
83,544 KB
testcase_20 AC 185 ms
83,444 KB
testcase_21 AC 218 ms
85,592 KB
testcase_22 AC 223 ms
82,448 KB
testcase_23 AC 125 ms
102,176 KB
testcase_24 AC 96 ms
78,244 KB
testcase_25 AC 106 ms
88,324 KB
testcase_26 AC 110 ms
90,300 KB
testcase_27 AC 93 ms
76,796 KB
testcase_28 AC 133 ms
107,648 KB
testcase_29 AC 138 ms
107,676 KB
testcase_30 AC 140 ms
80,940 KB
testcase_31 AC 130 ms
81,160 KB
testcase_32 AC 125 ms
81,248 KB
testcase_33 AC 129 ms
81,016 KB
testcase_34 AC 131 ms
80,904 KB
testcase_35 AC 133 ms
80,996 KB
testcase_36 AC 139 ms
81,140 KB
testcase_37 AC 126 ms
81,004 KB
testcase_38 AC 124 ms
81,192 KB
testcase_39 AC 130 ms
81,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, random
input = lambda : sys.stdin.readline().rstrip()


write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))
debug = lambda x: sys.stderr.write(x+"\n")
YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18
LI = lambda : list(map(int, input().split())); II=lambda : int(input())
def debug(_l_):
    for s in _l_.split():
        print(f"{s}={eval(s)}", end=" ")
    print()
def dlist(*l, fill=0):
    if len(l)==1:
        return [fill]*l[0]
    ll = l[1:]
    return [dlist(*ll, fill=fill) for _ in range(l[0])]

n = int(input())
a = list(map(int, input().split()))
m = 16
mask = (1<<m) - 1
if n>=m:
    ans = (1<<m) - 1
else:
    dp = [0]*(1<<m)
    dp[0] = 1
    for v in a:
        ndp = [0]*(1<<m)
        for i in range(m):
            for j in range(1<<m):
                nj = j|v
                if dp[j]:
                    ndp[nj] |= 1
            v = ((v>>1) | ((1<<15)*(v%2)))
        dp = ndp
    for i in range(1<<m)[::-1]:
        if dp[i]:
            ans = i
            break
print(ans)
0