結果
問題 |
No.1457 ツブ消ししとるなHard
|
ユーザー |
👑 |
提出日時 | 2022-03-29 20:12:14 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 1,059 bytes |
コンパイル時間 | 421 ms |
コンパイル使用メモリ | 5,632 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-08 18:32:59 |
合計ジャッジ時間 | 1,602 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
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)