結果

問題 No.1443 Andd
ユーザー 👑 obakyanobakyan
提出日時 2021-07-24 17:56:48
言語 Lua
(LuaJit 2.1.1696795921)
結果
MLE  
実行時間 -
コード長 936 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 528,920 KB
最終ジャッジ日時 2023-09-27 06:09:41
合計ジャッジ時間 7,842 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 32 ms
19,440 KB
testcase_04 AC 42 ms
19,464 KB
testcase_05 AC 34 ms
19,532 KB
testcase_06 AC 29 ms
19,224 KB
testcase_07 AC 40 ms
19,536 KB
testcase_08 AC 38 ms
19,528 KB
testcase_09 AC 7 ms
4,676 KB
testcase_10 AC 47 ms
19,480 KB
testcase_11 AC 41 ms
19,512 KB
testcase_12 AC 41 ms
19,468 KB
testcase_13 AC 251 ms
135,132 KB
testcase_14 AC 243 ms
135,184 KB
testcase_15 AC 243 ms
135,184 KB
testcase_16 AC 244 ms
135,156 KB
testcase_17 AC 243 ms
135,300 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

local band = bit.band
local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local asum = {a[1]}
for i = 2, n do
  asum[i] = asum[i - 1] + a[i]
end
local all = {}
for i = 1, 1024 * n do
  all[i] = false
end
local dp1, dp2 = {}, {}
dp1 = {true}
dp2 = {false}
for i = 2, 1024 do
  dp1[i] = false
  dp2[i] = false
end
local ret = 1
all[asum[n] + 1] = true
for i = 1, n do
  local dpd1 = {}
  dpd2 = {}
  for j = 1, 1024 do
    dpd1[j] = false
    dpd2[j] = false
  end
  local ai = a[i]
  for j = 1, 1024 do
    if dp1[j] or dp2[j] then
      local dst1 = band(j - 1, ai) + 1
      local dst2 = ((j - 1 + ai) % 1024) + 1
      dpd1[dst1] = true
      dpd2[dst2] = true
    end
  end
  for j = 1, 1024 do
    dp1[j] = dpd1[j]
    dp2[j] = dpd2[j]
  end
  for j = 1, 1024 do
    local v = j + asum[n] - asum[i]
    if dp1[j] and not all[v] then
      ret = ret + 1
      all[v] = true
    end
  end
  print(ret)
end
0