Submission #17059291


Source Code Expand

defmodule Main do
  def main do
    n = IO.read(:line) |> String.trim() |> String.to_integer()
    list = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)

    solve(n, list) |> IO.puts()
  end

  def solve(n, list) do
    0..(n - 1)
    |> Enum.reduce({Enum.sum(list), 0}, fn i, {sum, ans} ->
      sum = sum - Enum.at(list, i)
      ans = ans + sum * Enum.at(list, i)
      {sum, ans}
    end)
    |> elem(1)
    |> rem(1000000007)
  end
end

Submission Info

Submission Time
Task C - Sum of product of pairs
User awesomey
Language Elixir (1.10.2)
Score 0
Code Size 499 Byte
Status TLE
Exec Time 2208 ms
Memory 79180 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 6
TLE × 13
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, hand_02.txt, hand_03.txt, max_01.txt, max_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 409 ms 30720 KiB
hand_02.txt AC 396 ms 30564 KiB
hand_03.txt AC 393 ms 30652 KiB
max_01.txt TLE 2208 ms 64324 KiB
max_02.txt TLE 2208 ms 71368 KiB
random_01.txt TLE 2207 ms 60080 KiB
random_02.txt TLE 2208 ms 78828 KiB
random_03.txt AC 1083 ms 32448 KiB
random_04.txt TLE 2208 ms 78784 KiB
random_05.txt TLE 2207 ms 41272 KiB
random_06.txt TLE 2208 ms 78804 KiB
random_07.txt TLE 2207 ms 36604 KiB
random_08.txt TLE 2208 ms 78808 KiB
random_09.txt TLE 2207 ms 44172 KiB
random_10.txt TLE 2208 ms 78788 KiB
random_11.txt TLE 2208 ms 78988 KiB
random_12.txt TLE 2208 ms 79180 KiB
sample_01.txt AC 403 ms 30516 KiB
sample_02.txt AC 394 ms 30724 KiB