結果
問題 |
No.190 Dry Wet Moist
|
ユーザー |
👑 |
提出日時 | 2022-04-03 19:19:05 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 206 ms / 2,000 ms |
コード長 | 886 bytes |
コンパイル時間 | 238 ms |
コンパイル使用メモリ | 5,120 KB |
実行使用メモリ | 12,068 KB |
最終ジャッジ日時 | 2024-11-24 01:18:50 |
合計ジャッジ時間 | 4,826 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
local n = io.read("*n") * 2 local a = {} for i = 1, n do a[i] = io.read("*n") end table.sort(a) local right = n local minus = 0 for i = 1, n do local ai = a[i] while i < right and 0 <= ai + a[right] do right = right - 1 end if right <= i then break end minus = minus + 1 right = right - 1 end local plus = 0 local left = 1 for i = n, 1, -1 do local ai = a[i] while left < i and a[left] + ai <= 0 do left = left + 1 end if i <= left then break end plus = plus + 1 left = left + 1 end local am = {} for i = 1, n do local ai = a[i] if not am[ai] then am[ai] = 1 else am[ai] = am[ai] + 1 end end local center = 0 for k, v in pairs(am) do if k == 0 then center = center + math.floor(v / 2) elseif 0 < k then if am[-k] then center = center + math.min(v, am[-k]) end end end print(minus .. " " .. plus .. " " .. center)