結果
問題 | No.1858 Gorgeous Knapsack |
ユーザー |
👑 |
提出日時 | 2022-03-10 23:14:13 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 65 ms / 2,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 237 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 23:22:49 |
合計ジャッジ時間 | 1,804 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 37 |
ソースコード
local mmi, mma = math.min, math.maxlocal m, n = io.read("*n", "*n")local t = {}for i = 1, m dot[i] = {io.read("*n", "*n")}endtable.sort(t, function(a, b) return a[1] > b[1] end)local z = {}for i = 1, n + 1 doz[i] = 0endlocal ret = 0LLfor i = 1, m dolocal v, w = t[i][1], t[i][2]for j = n + 1 - w, 1, -1 doz[j + w] = mma(z[j + w], z[j] + v)endlocal cand = 1LL * z[n + 1] * vif ret < cand then ret = cand endendret = tostring(ret):gsub("LL", "")print(ret)