結果
問題 | 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") * 2local a = {}for i = 1, n do a[i] = io.read("*n") endtable.sort(a)local right = nlocal minus = 0for i = 1, n dolocal ai = a[i]while i < right and 0 <= ai + a[right] doright = right - 1endif right <= i then break endminus = minus + 1right = right - 1endlocal plus = 0local left = 1for i = n, 1, -1 dolocal ai = a[i]while left < i and a[left] + ai <= 0 doleft = left + 1endif i <= left then break endplus = plus + 1left = left + 1endlocal am = {}for i = 1, n dolocal ai = a[i]if not am[ai] thenam[ai] = 1elseam[ai] = am[ai] + 1endendlocal center = 0for k, v in pairs(am) doif k == 0 thencenter = center + math.floor(v / 2)elseif 0 < k thenif am[-k] thencenter = center + math.min(v, am[-k])endendendprint(minus .. " " .. plus .. " " .. center)