結果

問題 No.1268 Fruit Rush 2
ユーザー 👑 obakyanobakyan
提出日時 2021-07-29 22:57:46
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 650 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 22,348 KB
最終ジャッジ日時 2023-10-12 21:11:03
合計ジャッジ時間 13,555 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,480 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,356 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 469 ms
13,668 KB
testcase_17 AC 378 ms
13,140 KB
testcase_18 AC 421 ms
12,988 KB
testcase_19 AC 400 ms
13,052 KB
testcase_20 AC 389 ms
12,928 KB
testcase_21 AC 387 ms
13,056 KB
testcase_22 AC 432 ms
13,692 KB
testcase_23 AC 441 ms
13,688 KB
testcase_24 AC 385 ms
13,072 KB
testcase_25 AC 382 ms
12,932 KB
testcase_26 AC 639 ms
19,300 KB
testcase_27 AC 624 ms
19,316 KB
testcase_28 AC 646 ms
19,308 KB
testcase_29 AC 650 ms
19,400 KB
testcase_30 AC 645 ms
19,384 KB
testcase_31 AC 622 ms
18,548 KB
testcase_32 AC 605 ms
18,568 KB
testcase_33 AC 556 ms
22,296 KB
testcase_34 AC 463 ms
18,704 KB
testcase_35 AC 577 ms
22,348 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 n = io.read("*n", "*l")
local s = io.read()
local a = {}
for w in s:gmatch("%d+") do
  table.insert(a, lltonumber(w))
end
table.sort(a)
local len = {}
for i = 1, n do
  len[i] = 0
end
for i = n - 1, 1, -1 do
  if a[i] + 2LL == a[i + 1] then
    len[i] = len[i + 1] + 1
  elseif i + 2 <= n and a[i] + 2LL == a[i + 2] then
    len[i] = len[i + 2] + 1
  else
    len[i] = 0
  end
end
local ret = n
for i = 1, n - 1 do
  if a[i] + 1LL == a[i + 1] then
    ret = ret + 1 + len[i + 1]
  end
end
print(ret)
0