結果
問題 | No.247 線形計画問題もどき |
ユーザー |
👑 |
提出日時 | 2022-10-27 12:59:36 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 437 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 6,816 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-04 22:54:20 |
合計ジャッジ時間 | 1,310 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 23 |
ソースコード
local c = io.read("*n") local n = io.read("*n") local a = {} for i = 1, n do a[i] = io.read("*n") end local t = {} for i = 1, c do t[i] = -1 end for i = 1, n do local ai = a[i] if ai <= c then if t[ai] < 0 or 1 < t[ai] then t[ai] = 1 end end for j = 1, c - ai do local dst = j + ai if 0 <= t[j] then if t[dst] < 0 or t[j] + 1 < t[dst] then t[dst] = t[j] + 1 end end end end print(t[c])