結果

問題 No.2071 Shift and OR
ユーザー shotoyooshotoyoo
提出日時 2022-09-16 21:29:09
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 270 ms
使用メモリ 112,308 KB
最終ジャッジ日時 2023-01-11 06:00:34
合計ジャッジ時間 7,683 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 109 ms
83,640 KB
testcase_01 AC 111 ms
84,348 KB
testcase_02 AC 116 ms
85,136 KB
testcase_03 AC 143 ms
86,208 KB
testcase_04 AC 128 ms
85,680 KB
testcase_05 AC 171 ms
88,240 KB
testcase_06 AC 130 ms
85,868 KB
testcase_07 AC 121 ms
85,444 KB
testcase_08 AC 126 ms
85,892 KB
testcase_09 AC 127 ms
85,948 KB
testcase_10 AC 130 ms
85,876 KB
testcase_11 AC 172 ms
88,236 KB
testcase_12 AC 173 ms
88,448 KB
testcase_13 AC 166 ms
88,172 KB
testcase_14 AC 103 ms
83,036 KB
testcase_15 AC 151 ms
86,704 KB
testcase_16 AC 151 ms
86,952 KB
testcase_17 AC 179 ms
88,492 KB
testcase_18 AC 109 ms
84,424 KB
testcase_19 AC 196 ms
88,820 KB
testcase_20 AC 189 ms
89,068 KB
testcase_21 AC 219 ms
90,932 KB
testcase_22 AC 214 ms
89,584 KB
testcase_23 AC 129 ms
108,864 KB
testcase_24 AC 99 ms
82,852 KB
testcase_25 AC 110 ms
93,200 KB
testcase_26 AC 113 ms
94,724 KB
testcase_27 AC 94 ms
81,160 KB
testcase_28 AC 132 ms
112,308 KB
testcase_29 AC 132 ms
112,200 KB
testcase_30 AC 141 ms
86,672 KB
testcase_31 AC 128 ms
86,308 KB
testcase_32 AC 126 ms
86,612 KB
testcase_33 AC 129 ms
86,220 KB
testcase_34 AC 133 ms
86,432 KB
testcase_35 AC 136 ms
86,296 KB
testcase_36 AC 142 ms
86,472 KB
testcase_37 AC 130 ms
86,652 KB
testcase_38 AC 129 ms
86,492 KB
testcase_39 AC 129 ms
86,156 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