結果

問題 No.2110 012 Matching
ユーザー 👑 obakyanobakyan
提出日時 2022-10-29 00:56:16
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 08:07:29
合計ジャッジ時間 4,257 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

local ffi = require("ffi")
local C = ffi.C
ffi.cdef[[
long long atoll(const char*);
]]

local function lltonumber(str)
  return C.atoll(str)
end
local function llmin(x, y) return x < y and x or y end

local q = io.read("*n", "*l")
for iq = 1, q do
  local a, b, c = io.read():match("(%d+) (%d+) (%d+)")
  a = lltonumber(a)
  b = lltonumber(b)
  c = lltonumber(c)
  
  d = llmin(a, c)
  s = 2LL * d
  a = a - d
  c = c - d
  if b % 2LL == 1LL then
    s = s + b - 1LL
    b = 1LL
  else
    s = s + b
    b = 0LL
  end
  if 0LL == a then
    if (a + b) % 2LL == 0 then
      z = a + b * 2LL - (a + b) / 2LL * 3LL
      s = s + z
    else
      if a == 1LL then
        s = s + b / 2LL
      else
        s = s + (b - 1LL) / 2LL
      end
    end
  else
    s = s + llmin(a, b)
  end
  s = tostring(s):gsub("LL", "")
  print(s)
end
0