結果

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

テストケース

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

ソースコード

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 (b + c) % 2LL == 0 then
      z = b + c * 2LL - (b + c) / 2LL * 3LL
      s = s + z
    else
      if b == 1LL then
        s = s + c / 2LL
      else
        s = s + (c - 1LL) / 2LL
      end
    end
  else
    s = s + llmin(a, b)
  end
  s = tostring(s):gsub("LL", "")
  print(s)
end
0