結果
問題 | No.2071 Shift and OR |
ユーザー |
![]() |
提出日時 | 2022-09-16 22:56:06 |
言語 | PyPy3 (7.3.8) |
結果 |
AC
|
実行時間 | 153 ms / 2,000 ms |
コード長 | 1,149 bytes |
コンパイル時間 | 260 ms |
使用メモリ | 111,488 KB |
最終ジャッジ日時 | 2023-01-11 08:13:38 |
合計ジャッジ時間 | 7,300 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 110 ms
82,948 KB |
testcase_01 | AC | 115 ms
83,396 KB |
testcase_02 | AC | 122 ms
84,292 KB |
testcase_03 | AC | 127 ms
85,300 KB |
testcase_04 | AC | 126 ms
84,752 KB |
testcase_05 | AC | 141 ms
86,944 KB |
testcase_06 | AC | 124 ms
84,920 KB |
testcase_07 | AC | 121 ms
84,380 KB |
testcase_08 | AC | 127 ms
84,804 KB |
testcase_09 | AC | 124 ms
84,784 KB |
testcase_10 | AC | 125 ms
84,864 KB |
testcase_11 | AC | 145 ms
87,448 KB |
testcase_12 | AC | 144 ms
87,632 KB |
testcase_13 | AC | 140 ms
86,932 KB |
testcase_14 | AC | 107 ms
82,224 KB |
testcase_15 | AC | 132 ms
86,012 KB |
testcase_16 | AC | 132 ms
86,000 KB |
testcase_17 | AC | 145 ms
87,224 KB |
testcase_18 | AC | 113 ms
83,228 KB |
testcase_19 | AC | 146 ms
87,896 KB |
testcase_20 | AC | 147 ms
87,712 KB |
testcase_21 | AC | 98 ms
75,908 KB |
testcase_22 | AC | 153 ms
88,728 KB |
testcase_23 | AC | 137 ms
107,868 KB |
testcase_24 | AC | 107 ms
81,712 KB |
testcase_25 | AC | 120 ms
93,056 KB |
testcase_26 | AC | 121 ms
95,128 KB |
testcase_27 | AC | 103 ms
80,996 KB |
testcase_28 | AC | 141 ms
111,488 KB |
testcase_29 | AC | 140 ms
111,488 KB |
testcase_30 | AC | 128 ms
85,336 KB |
testcase_31 | AC | 129 ms
85,544 KB |
testcase_32 | AC | 129 ms
85,380 KB |
testcase_33 | AC | 129 ms
85,516 KB |
testcase_34 | AC | 130 ms
85,400 KB |
testcase_35 | AC | 129 ms
85,316 KB |
testcase_36 | AC | 129 ms
85,300 KB |
testcase_37 | AC | 128 ms
85,496 KB |
testcase_38 | AC | 129 ms
85,376 KB |
testcase_39 | AC | 129 ms
85,132 KB |
ソースコード
import sys #input = sys.stdin.readline #input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) import math #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush from collections import defaultdict from collections import deque #import copy #DeepCopy: hoge = [_[:] for _ in hogehoge] #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] #dx8 = [1,1,0,-1,-1,-1,0,1] #dy8 = [0,1,1,1,0,-1,-1,-1] def shift(x): return x//2 + pow(2,15) * (x%2) def main(): N = int(input()) A = list(map(int,input().split())) if N >= 15: ans = 1 << 16 print(ans-1);exit() M = 1 << 16 # dp[mask]: maskの値となるかどうか dp = [0]*M dp[0] = 1 for a in A: p = [0]*M p,dp = dp,p for x in range(16): a = shift(a) for mask in range(M): dp[mask|a] |= p[mask] for i in reversed(range(M)): if dp[i] == 1: print(i) exit() if __name__ == '__main__': main()