結果

問題 No.1457 ツブ消ししとるなHard
ユーザー 👑 obakyanobakyan
提出日時 2022-03-29 20:12:14
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,059 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-26 05:44:47
合計ジャッジ時間 1,290 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 52 ms
10,368 KB
testcase_05 AC 57 ms
10,880 KB
testcase_06 AC 52 ms
10,368 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 19 ms
7,040 KB
testcase_13 AC 7 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 6 ms
6,940 KB
testcase_16 AC 5 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 40 ms
8,960 KB
testcase_20 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma = math.min, math.max
local n, m = io.read("*n", "*n")
local x, y, z = io.read("*n", "*n", "*n")
local a = {}
local c = 0
for i = 1, n do
  a[i] = io.read("*n")
  if x <= a[i] then c = c + 1 end
end
if m < c then print("Handicapped") os.exit() end
local t = {}
local lim = 2500
for i = 1, m do
  t[i] = {}
  for j = 1, lim do
    t[i][j] = 0LL
  end
end
local asum = 0
local acnt = 0
local biassum = 0
local biascnt = 0
for i = 1, n do
  local ai = a[i]
  if x <= ai then
    biassum = biassum + ai
    biascnt = biascnt + 1
  elseif y < ai then
    local alim = mmi(m - 1, acnt)
    for j = alim, 1, -1 do
      for k = asum, 1, -1 do
        t[j + 1][k + ai] = t[j + 1][k + ai] + t[j][k]
      end
    end
    t[1][ai] = t[1][ai] + 1LL
    asum = asum + ai
    acnt = acnt + 1
  end
end
local ans = 0LL
if 0 < biascnt and biascnt * z == biassum then
  ans = ans + 1LL
end
for i = 1, m do
  for j = 1, lim do
    if (i + biascnt) * z == j + biassum then
      ans = ans + t[i][j]
    end
  end
end
ans = tostring(ans):gsub("LL", "")
print(ans)
0