結果
問題 |
No.967 引き算をして門松列(その2)
|
ユーザー |
👑 |
提出日時 | 2020-03-31 22:18:24 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,497 bytes |
コンパイル時間 | 302 ms |
コンパイル使用メモリ | 5,504 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 07:02:18 |
合計ジャッジ時間 | 1,323 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 WA * 3 |
ソースコード
local t = io.read("*n") for it = 1, t do local a, b, c = io.read("*n", "*n", "*n") local x, y, z = io.read("*n", "*n", "*n") local inf = 1000000007LL * 1000000007LL local ret = inf do -- b < a < c local ta, tb, tc = a, b, c local cost = 0LL if tc <= ta then cost = cost + x * (ta + 1 - tc) ta = tc - 1 end if ta <= tb then cost = cost + y * (tb + 1 - ta) tb = ta - 1 end if 0 < tb and cost < ret then ret = cost end end do -- b < c < a local ta, tb, tc = a, b, c local cost = 0LL if ta <= tc then cost = cost + z * (tc + 1 - ta) tc = ta - 1 end if tc <= tb then cost = cost + y * (tb + 1 - tc) tb = tc - 1 end if 0 < tb and cost < ret then ret = cost end end do -- a < c < b local ta, tb, tc = a, b, c local cost = 0LL if tb <= tc then cost = cost + z * (tc + 1 - tb) tc = tb - 1 end if tc <= ta then cost = cost + x * (ta + 1 - tc) ta = tc - 1 end if 0 < ta and cost < ret then ret = cost end end do -- c < a < b local ta, tb, tc = a, b, c local cost = 0LL if tb <= ta then cost = cost + x * (ta + 1 - tb) ta = tb - 1 end if ta <= tc then cost = cost + z * (tc + 1 - ta) tc = ta - 1 end if 0 < tc and cost < ret then ret = cost end end if ret == inf then print(-1) else local str = tostring(ret):gsub("LL", "") print(str) end end