結果
問題 | No.2071 Shift and OR |
ユーザー |
![]() |
提出日時 | 2022-09-19 00:16:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 120 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 227 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 101,696 KB |
最終ジャッジ日時 | 2024-12-22 01:54:02 |
合計ジャッジ時間 | 4,168 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
N = int(input())A = list(map(int,input().split()))if N >= 16:print((1<<16)-1)exit()dp = [[False] *(1<<16) for _ in range(N)]def shift(x):return x//2 + (1<<15) *(x%2)B = [[] for _ in range(N)]for i in range(N):x = A[i]for _ in range(16):x = shift(x)B[i].append(x)for x in B[0]:dp[0][x] = Truefor i in range(N-1):for s in range(1<<16):if dp[i][s]:for x in B[i+1]:dp[i+1][s|x] = Truefor s in reversed(range(1<<16)):if dp[N-1][s]:print(s)exit()