結果

問題 No.2390 Udon Coupon (Hard)
ユーザー 👑 obakyanobakyan
提出日時 2023-07-23 21:57:59
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 594 ms / 2,000 ms
コード長 734 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 21:09:05
合計ジャッジ時間 9,130 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 578 ms
5,248 KB
testcase_01 AC 37 ms
5,376 KB
testcase_02 AC 41 ms
5,376 KB
testcase_03 AC 40 ms
5,376 KB
testcase_04 AC 42 ms
5,376 KB
testcase_05 AC 34 ms
5,376 KB
testcase_06 AC 568 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 40 ms
5,376 KB
testcase_10 AC 214 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 30 ms
5,376 KB
testcase_14 AC 186 ms
5,376 KB
testcase_15 AC 13 ms
5,376 KB
testcase_16 AC 29 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 50 ms
5,376 KB
testcase_19 AC 48 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 42 ms
5,376 KB
testcase_23 AC 42 ms
5,376 KB
testcase_24 AC 44 ms
5,376 KB
testcase_25 AC 43 ms
5,376 KB
testcase_26 AC 43 ms
5,376 KB
testcase_27 AC 42 ms
5,376 KB
testcase_28 AC 43 ms
5,376 KB
testcase_29 AC 42 ms
5,376 KB
testcase_30 AC 43 ms
5,376 KB
testcase_31 AC 43 ms
5,376 KB
testcase_32 AC 43 ms
5,376 KB
testcase_33 AC 42 ms
5,376 KB
testcase_34 AC 43 ms
5,376 KB
testcase_35 AC 43 ms
5,376 KB
testcase_36 AC 43 ms
5,376 KB
testcase_37 AC 43 ms
5,376 KB
testcase_38 AC 42 ms
5,376 KB
testcase_39 AC 41 ms
5,376 KB
testcase_40 AC 584 ms
5,376 KB
testcase_41 AC 576 ms
5,376 KB
testcase_42 AC 586 ms
5,376 KB
testcase_43 AC 572 ms
5,376 KB
testcase_44 AC 577 ms
5,376 KB
testcase_45 AC 594 ms
5,376 KB
testcase_46 AC 41 ms
5,376 KB
testcase_47 AC 582 ms
5,376 KB
testcase_48 AC 580 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local n = io.read("*n")
local a, b = {}, {}
for i = 1, 3 do
  a[i], b[i] = io.read("*n", "*n")
  b[i] = 1LL * b[i]
end
local ans = 0LL
local function solve(a1, a2, a3, b1, b2, b3)
  for i = 0, 2000 do
    for j = 0, 2000 do
      local use_sum = a1 * i + a2 * j
      if use_sum <= n then
        local rem = n - use_sum
        local k = mfl(rem / a3)
        local v = b1 * i + b2 * j + b3 * k
        if ans < v then ans = v end 
      else
        break
      end
    end
  end
end

solve(a[1], a[2], a[3], b[1], b[2], b[3])
solve(a[1], a[3], a[2], b[1], b[3], b[2])
solve(a[2], a[3], a[1], b[2], b[3], b[1])
ans = tostring(ans):gsub("LL", "")
print(ans)
0