結果

問題 No.1623 三角形の制作
ユーザー 👑 obakyanobakyan
提出日時 2021-07-24 09:37:30
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 5,408 KB
実行使用メモリ 5,892 KB
最終ジャッジ日時 2023-09-26 15:22:16
合計ジャッジ時間 4,811 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
4,380 KB
testcase_01 AC 20 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 34 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 36 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 20 ms
4,376 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 = 0
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 + a[ia] * b[ib] * v
    end
  end
end
print(ret)
0