結果

問題 No.1623 三角形の制作
ユーザー 👑 obakyanobakyan
提出日時 2021-07-24 09:38:20
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 5,068 KB
実行使用メモリ 5,940 KB
最終ジャッジ日時 2023-09-26 15:24:06
合計ジャッジ時間 3,333 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
4,508 KB
testcase_01 AC 22 ms
4,384 KB
testcase_02 AC 76 ms
4,532 KB
testcase_03 AC 73 ms
4,388 KB
testcase_04 AC 74 ms
4,380 KB
testcase_05 AC 114 ms
5,940 KB
testcase_06 AC 37 ms
4,388 KB
testcase_07 AC 74 ms
4,380 KB
testcase_08 AC 38 ms
4,384 KB
testcase_09 AC 70 ms
4,388 KB
testcase_10 AC 98 ms
5,272 KB
testcase_11 AC 82 ms
4,600 KB
testcase_12 AC 49 ms
4,384 KB
testcase_13 AC 54 ms
4,380 KB
testcase_14 AC 56 ms
4,384 KB
testcase_15 AC 102 ms
4,384 KB
testcase_16 AC 100 ms
4,380 KB
testcase_17 AC 99 ms
4,380 KB
testcase_18 AC 104 ms
4,384 KB
testcase_19 AC 63 ms
4,384 KB
testcase_20 AC 23 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n = io.read("*n", "*l")
local astr = io.read()
local bstr = io.read()
local cstr = io.read()
local a, b, c = {}, {}, {}
for i = 1, 3000 do
  a[i], b[i], c[i] = 0, 0, 0
end
for w in astr:gmatch("%d+") do
  local z = tonumber(w)
  a[z] = a[z] + 1
end
for w in bstr:gmatch("%d+") do
  local z = tonumber(w)
  b[z] = b[z] + 1
end
for w in cstr:gmatch("%d+") do
  local z = tonumber(w)
  c[z] = c[z] + 1
end
local csum = {c[1]}
for i = 2, 3000 do
  csum[i] = c[i] + csum[i - 1]
end
local ret = 0LL
for ia = 1, 3000 do
  for ib = 1, ia do
    local cmax = ia
    local cmin = ia - ib + 1
    if cmin <= cmax then
      local v = csum[cmax]
      if 1 < cmin then
        v = v - csum[cmin - 1]
      end
      ret = ret + 1LL * a[ia] * b[ib] * v
    end
  end
end
ret = tostring(ret):gsub("LL", "")
print(ret)
0