結果
問題 | No.1268 Fruit Rush 2 |
ユーザー |
👑 |
提出日時 | 2021-07-29 22:57:46 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 565 ms / 2,000 ms |
コード長 | 653 bytes |
コンパイル時間 | 323 ms |
コンパイル使用メモリ | 6,688 KB |
実行使用メモリ | 22,552 KB |
最終ジャッジ日時 | 2024-09-14 19:29:47 |
合計ジャッジ時間 | 11,889 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
local ffi = require("ffi")local C = ffi.Cffi.cdef[[long long atoll(const char*);]]local function lltonumber(str)return C.atoll(str)endlocal n = io.read("*n", "*l")local s = io.read()local a = {}for w in s:gmatch("%d+") dotable.insert(a, lltonumber(w))endtable.sort(a)local len = {}for i = 1, n dolen[i] = 0endfor i = n - 1, 1, -1 doif a[i] + 2LL == a[i + 1] thenlen[i] = len[i + 1] + 1elseif i + 2 <= n and a[i] + 2LL == a[i + 2] thenlen[i] = len[i + 2] + 1elselen[i] = 0endendlocal ret = nfor i = 1, n - 1 doif a[i] + 1LL == a[i + 1] thenret = ret + 1 + len[i + 1]endendprint(ret)