結果

問題 No.2071 Shift and OR
ユーザー maguroflymagurofly
提出日時 2022-09-16 21:48:13
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 354 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 11,240 KB
実行使用メモリ 23,488 KB
最終ジャッジ日時 2023-08-23 14:52:04
合計ジャッジ時間 31,166 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 344 ms
16,888 KB
testcase_01 AC 478 ms
17,452 KB
testcase_02 AC 741 ms
18,328 KB
testcase_03 AC 1,029 ms
19,332 KB
testcase_04 AC 890 ms
18,720 KB
testcase_05 AC 1,448 ms
20,864 KB
testcase_06 AC 895 ms
18,844 KB
testcase_07 AC 753 ms
18,300 KB
testcase_08 AC 889 ms
18,856 KB
testcase_09 AC 888 ms
18,720 KB
testcase_10 AC 896 ms
18,916 KB
testcase_11 AC 1,582 ms
21,236 KB
testcase_12 AC 1,582 ms
21,240 KB
testcase_13 AC 1,447 ms
20,828 KB
testcase_14 AC 221 ms
16,140 KB
testcase_15 AC 1,176 ms
19,772 KB
testcase_16 AC 1,177 ms
19,860 KB
testcase_17 AC 1,584 ms
21,348 KB
testcase_18 AC 473 ms
17,316 KB
testcase_19 AC 1,748 ms
21,932 KB
testcase_20 AC 1,728 ms
21,800 KB
testcase_21 TLE -
testcase_22 AC 1,871 ms
22,360 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_s.to_i
A = gets.to_s.split.map(&:to_i)

dp = [false] * 65536
dp[0] = true

A.each do |n|
    dp2 = [false] * 65536
    16.times do |i|
        (0 ... 65536).each do |m|
            dp2[m | n] |= dp[m]
        end
        n = n >> 1 | (n & 1) << 15
    end
    dp = dp2
end

ans = 0
(0 ... 65536).each do |i|
    ans = i if dp[i]
end

puts ans
0