結果

問題 No.2462 七人カノン
ユーザー 👑 obakyanobakyan
提出日時 2023-10-26 00:07:35
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 5,328 KB
実行使用メモリ 11,212 KB
最終ジャッジ日時 2023-10-26 00:07:44
合計ジャッジ時間 8,833 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 4 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 5 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 4 ms
4,348 KB
testcase_07 AC 5 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 5 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 71 ms
9,908 KB
testcase_14 AC 71 ms
9,908 KB
testcase_15 AC 70 ms
9,908 KB
testcase_16 AC 104 ms
10,156 KB
testcase_17 AC 77 ms
10,156 KB
testcase_18 AC 9 ms
5,184 KB
testcase_19 AC 8 ms
5,184 KB
testcase_20 AC 75 ms
10,948 KB
testcase_21 AC 75 ms
10,948 KB
testcase_22 AC 77 ms
11,212 KB
testcase_23 AC 75 ms
10,948 KB
testcase_24 AC 46 ms
8,108 KB
testcase_25 AC 83 ms
11,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, q = io.read("*n", "*n")
local p, s, t = {}, {}, {}
local a = {}
local lim = 100001
for i = 1, lim do
  a[i] = 0
end
for i = 1, q do
  local pi, si, ti = io.read("*n", "*n", "*n")
  si = si + 1
  ti = ti + 1
  p[i], s[i], t[i] = pi, si, ti
  a[si] = a[si] + 1
  a[ti] = a[ti] - 1
end
for i = 2, lim do
  a[i] = a[i - 1] + a[i]
end
for i = 1, lim do
  if 0 < a[i] then
    a[i] = 1 / a[i]
  end
end
for i = 2, lim do
  a[i] = a[i - 1] + a[i]
end
local ans = {}
for i = 1, n do
  ans[i] = 0
end
for i = 1, q do
  local pi, si, ti = p[i], s[i], t[i]
  ans[pi] = ans[pi] + a[ti - 1]
  if 1 < si then
    ans[pi] = ans[pi] - a[si - 1]
  end
end
print(table.concat(ans, "\n"))
0