結果
| 問題 |
No.2110 012 Matching
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-10-29 00:59:45 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 233 ms / 2,000 ms |
| コード長 | 830 bytes |
| コンパイル時間 | 27 ms |
| コンパイル使用メモリ | 6,688 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 03:58:50 |
| 合計ジャッジ時間 | 2,762 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
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