結果

問題 No.1443 Andd
ユーザー 👑 obakyanobakyan
提出日時 2021-07-24 16:16:59
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
実行時間 -
コード長 732 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 137,992 KB
最終ジャッジ日時 2023-09-27 04:26:10
合計ジャッジ時間 12,710 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 637 ms
18,628 KB
testcase_04 AC 1,585 ms
18,604 KB
testcase_05 AC 711 ms
18,776 KB
testcase_06 AC 534 ms
18,764 KB
testcase_07 AC 1,459 ms
18,680 KB
testcase_08 AC 1,165 ms
18,704 KB
testcase_09 AC 22 ms
4,376 KB
testcase_10 TLE -
testcase_11 AC 1,729 ms
18,772 KB
testcase_12 AC 1,662 ms
18,788 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

local band = bit.band
local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local dp1, dp2 = {}, {}
local lim = n * 1023
for i = 1, lim do
  dp1[i] = false
end
for i = 1, n do
  local src = i % 2 == 1 and dp1 or dp2
  local dst = i % 2 == 1 and dp2 or dp1
  for j = 1, lim do
    dst[j] = false
  end
  local cnt = 1
  local ai = a[i]
  for j = 1, lim do
    if src[j] then
      if 0 < j + ai and not dst[j + ai] then
        cnt = cnt + 1
        dst[j + ai] = true
      end
      local bb = band(j, ai)
      if 0 < bb and not dst[bb] then
        cnt = cnt + 1
        dst[bb] = true
      end
    end
  end
  if 0 < ai and not dst[ai] then
    cnt = cnt + 1
    dst[ai] = true
  end
  print(cnt)
end
0