結果
問題 | No.1000 Point Add and Array Add |
ユーザー | penqen |
提出日時 | 2021-03-29 16:46:37 |
言語 | Elixir (1.16.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 952 bytes |
コンパイル時間 | 1,114 ms |
コンパイル使用メモリ | 55,960 KB |
実行使用メモリ | 389,320 KB |
最終ジャッジ日時 | 2023-08-30 01:22:04 |
合計ジャッジ時間 | 18,365 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 550 ms
49,244 KB |
testcase_01 | AC | 539 ms
49,336 KB |
testcase_02 | AC | 544 ms
49,324 KB |
testcase_03 | AC | 555 ms
49,564 KB |
testcase_04 | AC | 559 ms
50,008 KB |
testcase_05 | AC | 553 ms
50,192 KB |
testcase_06 | AC | 546 ms
49,496 KB |
testcase_07 | AC | 552 ms
49,392 KB |
testcase_08 | AC | 551 ms
49,260 KB |
testcase_09 | AC | 562 ms
49,356 KB |
testcase_10 | AC | 554 ms
49,216 KB |
testcase_11 | AC | 554 ms
49,344 KB |
testcase_12 | AC | 655 ms
52,212 KB |
testcase_13 | AC | 577 ms
49,964 KB |
testcase_14 | AC | 847 ms
55,904 KB |
testcase_15 | AC | 789 ms
56,776 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
ソースコード
defmodule Main do def main do [n, q] = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) an = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.with_index() |> Enum.reduce(%{}, &(Map.put(&2, elem(&1, 1), String.to_integer(elem(&1, 0))))) queries = for _ <- 0..(q-1) do IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(fn v when v in ["A", "B"] -> v v -> String.to_integer(v) end) end solve(n, q, an, queries) |> Enum.join(" ") |> IO.puts() end def solve(n, _q, an, queries) do {_, bn} = Enum.reduce(queries, {an, Enum.reduce(0..(n-1), %{}, &(Map.put(&2, &1, 0)))}, fn ["A", x, y], {an, bn} -> {Map.put(an, x - 1, an[x - 1] + y), bn} ["B", x, y], {an, bn} -> {an, Enum.reduce((x - 1)..(y - 1), bn, &(Map.put(&2, &1, bn[&1] + an[&1])))} end) (n-1)..0 |> Enum.reduce([], fn i, acc -> [bn[i] | acc] end) end end