結果

問題 No.2071 Shift and OR
ユーザー shobonvipshobonvip
提出日時 2022-09-16 22:01:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 115,856 KB
最終ジャッジ日時 2023-08-23 15:31:21
合計ジャッジ時間 7,915 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
77,512 KB
testcase_01 AC 95 ms
77,928 KB
testcase_02 AC 103 ms
79,192 KB
testcase_03 AC 137 ms
80,036 KB
testcase_04 AC 117 ms
79,524 KB
testcase_05 AC 174 ms
81,724 KB
testcase_06 AC 122 ms
79,816 KB
testcase_07 AC 108 ms
79,000 KB
testcase_08 AC 115 ms
79,648 KB
testcase_09 AC 118 ms
79,436 KB
testcase_10 AC 120 ms
79,712 KB
testcase_11 AC 174 ms
82,236 KB
testcase_12 AC 176 ms
82,164 KB
testcase_13 AC 167 ms
81,700 KB
testcase_14 AC 79 ms
76,580 KB
testcase_15 AC 148 ms
80,688 KB
testcase_16 AC 148 ms
80,612 KB
testcase_17 AC 183 ms
82,100 KB
testcase_18 AC 92 ms
77,984 KB
testcase_19 AC 203 ms
82,556 KB
testcase_20 AC 195 ms
82,428 KB
testcase_21 AC 234 ms
84,620 KB
testcase_22 AC 225 ms
83,216 KB
testcase_23 AC 189 ms
112,428 KB
testcase_24 AC 154 ms
85,824 KB
testcase_25 AC 165 ms
97,096 KB
testcase_26 AC 170 ms
98,952 KB
testcase_27 AC 153 ms
85,572 KB
testcase_28 AC 190 ms
115,756 KB
testcase_29 AC 195 ms
115,856 KB
testcase_30 AC 136 ms
80,068 KB
testcase_31 AC 121 ms
80,208 KB
testcase_32 AC 120 ms
80,076 KB
testcase_33 AC 122 ms
80,036 KB
testcase_34 AC 127 ms
80,076 KB
testcase_35 AC 128 ms
80,104 KB
testcase_36 AC 134 ms
79,856 KB
testcase_37 AC 122 ms
80,040 KB
testcase_38 AC 119 ms
79,960 KB
testcase_39 AC 123 ms
80,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# BIT DP を行う
# A[i] > 0 だから, 最大16個見ればok 
# dp[i][j] : i番目まで見てjが到達可能

n = int(input())
a = list(map(int,input().split()))
dp = [[0] * (1 << 16) for i in range(min(n, 16) + 1)]
dp[0][0] = 1

for i in range(min(n, 16)):
	for j in range(16):
		for k in range(1 << 16):
			if dp[i][k] == 1:
				dp[i+1][k|a[i]] = 1
		a[i] = (a[i] // 2) + (1 << 15) * (a[i] % 2)

r = 0
for i in range(1 << 16):
	if dp[min(n, 16)][i] == 1:
		r = i

print(r)
0