結果
問題 | No.967 引き算をして門松列(その2) |
ユーザー | 👑 obakyan |
提出日時 | 2020-03-31 22:18:24 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,497 bytes |
コンパイル時間 | 242 ms |
コンパイル使用メモリ | 5,352 KB |
実行使用メモリ | 4,508 KB |
最終ジャッジ日時 | 2023-09-07 12:58:23 |
合計ジャッジ時間 | 1,205 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,384 KB |
testcase_01 | AC | 1 ms
4,508 KB |
testcase_02 | AC | 1 ms
4,384 KB |
testcase_03 | AC | 11 ms
4,380 KB |
testcase_04 | AC | 12 ms
4,380 KB |
testcase_05 | AC | 11 ms
4,380 KB |
testcase_06 | AC | 12 ms
4,384 KB |
testcase_07 | AC | 12 ms
4,384 KB |
testcase_08 | AC | 20 ms
4,380 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
ソースコード
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