結果
| 問題 | No.1443 Andd | 
| コンテスト | |
| ユーザー | 👑 | 
| 提出日時 | 2021-07-24 16:16:59 | 
| 言語 | Lua (LuaJit 2.1.1734355927) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 732 bytes | 
| コンパイル時間 | 209 ms | 
| コンパイル使用メモリ | 5,248 KB | 
| 実行使用メモリ | 139,392 KB | 
| 最終ジャッジ日時 | 2024-07-19 22:11:00 | 
| 合計ジャッジ時間 | 17,034 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 TLE * 2 -- * 9 | 
ソースコード
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
            
            
            
        