結果
問題 | No.2071 Shift and OR |
ユーザー | ygd. |
提出日時 | 2022-09-16 22:56:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 1,149 bytes |
コンパイル時間 | 276 ms |
コンパイル使用メモリ | 87,012 KB |
実行使用メモリ | 107,384 KB |
最終ジャッジ日時 | 2023-08-23 16:25:36 |
合計ジャッジ時間 | 6,737 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 105 ms
78,368 KB |
testcase_01 | AC | 108 ms
78,776 KB |
testcase_02 | AC | 109 ms
79,860 KB |
testcase_03 | AC | 119 ms
80,740 KB |
testcase_04 | AC | 116 ms
80,364 KB |
testcase_05 | AC | 130 ms
82,344 KB |
testcase_06 | AC | 114 ms
80,372 KB |
testcase_07 | AC | 111 ms
79,552 KB |
testcase_08 | AC | 115 ms
80,248 KB |
testcase_09 | AC | 115 ms
80,456 KB |
testcase_10 | AC | 113 ms
80,196 KB |
testcase_11 | AC | 132 ms
83,044 KB |
testcase_12 | AC | 134 ms
82,788 KB |
testcase_13 | AC | 129 ms
82,380 KB |
testcase_14 | AC | 98 ms
77,820 KB |
testcase_15 | AC | 123 ms
81,300 KB |
testcase_16 | AC | 120 ms
81,484 KB |
testcase_17 | AC | 134 ms
82,996 KB |
testcase_18 | AC | 104 ms
78,668 KB |
testcase_19 | AC | 138 ms
83,368 KB |
testcase_20 | AC | 136 ms
83,524 KB |
testcase_21 | AC | 87 ms
71,300 KB |
testcase_22 | AC | 157 ms
84,532 KB |
testcase_23 | AC | 128 ms
103,580 KB |
testcase_24 | AC | 96 ms
77,596 KB |
testcase_25 | AC | 108 ms
88,620 KB |
testcase_26 | AC | 111 ms
90,840 KB |
testcase_27 | AC | 93 ms
76,868 KB |
testcase_28 | AC | 132 ms
107,356 KB |
testcase_29 | AC | 132 ms
107,384 KB |
testcase_30 | AC | 121 ms
80,568 KB |
testcase_31 | AC | 120 ms
80,900 KB |
testcase_32 | AC | 121 ms
80,980 KB |
testcase_33 | AC | 120 ms
80,720 KB |
testcase_34 | AC | 123 ms
80,732 KB |
testcase_35 | AC | 121 ms
80,788 KB |
testcase_36 | AC | 121 ms
80,528 KB |
testcase_37 | AC | 127 ms
80,948 KB |
testcase_38 | AC | 122 ms
80,892 KB |
testcase_39 | AC | 121 ms
80,748 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()