結果

問題 No.2071 Shift and OR
ユーザー terasaterasa
提出日時 2022-11-05 11:40:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 961 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 112,268 KB
最終ジャッジ日時 2023-09-26 11:30:11
合計ジャッジ時間 13,002 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 167 ms
81,716 KB
testcase_01 AC 186 ms
82,964 KB
testcase_02 AC 184 ms
86,104 KB
testcase_03 AC 199 ms
86,368 KB
testcase_04 AC 189 ms
85,584 KB
testcase_05 AC 230 ms
87,704 KB
testcase_06 AC 187 ms
86,192 KB
testcase_07 AC 180 ms
86,100 KB
testcase_08 AC 187 ms
86,400 KB
testcase_09 AC 189 ms
86,000 KB
testcase_10 AC 187 ms
86,192 KB
testcase_11 AC 221 ms
87,676 KB
testcase_12 AC 224 ms
87,940 KB
testcase_13 AC 215 ms
87,308 KB
testcase_14 AC 170 ms
81,788 KB
testcase_15 AC 211 ms
86,692 KB
testcase_16 AC 216 ms
86,912 KB
testcase_17 AC 225 ms
87,924 KB
testcase_18 AC 177 ms
83,164 KB
testcase_19 AC 257 ms
89,040 KB
testcase_20 AC 233 ms
88,752 KB
testcase_21 AC 272 ms
90,516 KB
testcase_22 AC 243 ms
89,824 KB
testcase_23 AC 201 ms
108,828 KB
testcase_24 AC 168 ms
83,548 KB
testcase_25 AC 185 ms
94,184 KB
testcase_26 AC 186 ms
95,660 KB
testcase_27 AC 165 ms
80,608 KB
testcase_28 AC 201 ms
111,964 KB
testcase_29 AC 203 ms
112,268 KB
testcase_30 AC 204 ms
86,312 KB
testcase_31 AC 192 ms
86,676 KB
testcase_32 AC 196 ms
86,252 KB
testcase_33 AC 195 ms
86,248 KB
testcase_34 AC 197 ms
86,148 KB
testcase_35 AC 197 ms
86,476 KB
testcase_36 AC 209 ms
86,436 KB
testcase_37 AC 196 ms
86,400 KB
testcase_38 AC 192 ms
86,324 KB
testcase_39 AC 189 ms
86,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List, Tuple, Optional
import sys
import itertools
import heapq
import bisect
from collections import deque, defaultdict
from functools import lru_cache, cmp_to_key

input = sys.stdin.readline

# for AtCoder Easy test
if __file__ != 'prog.py':
    sys.setrecursionlimit(10 ** 6)


def readints(): return map(int, input().split())
def readlist(): return list(readints())
def readstr(): return input().rstrip()


N = int(input())
A = readlist()

if N > 15:
    print((1 << 16) - 1)
    exit()

dp = [False] * (1 << 16)
dp[0] = True
for a in A:
    ndp = [False] * (1 << 16)
    for j in range(1 << 16):
        if dp[j] is False:
            continue
        acc = a
        for k in range(16):
            ndp[j | acc] = True
            if acc & 1:
                acc = (acc >> 1) + (1 << 15)
            else:
                acc = (acc >> 1)
    dp = ndp

for s in range(1 << 16)[::-1]:
    if dp[s] is True:
        print(s)
        break
0