結果

問題 No.1046 Fruits Rush
ユーザー penqenpenqen
提出日時 2020-12-16 14:16:22
言語 Elixir
(1.16.2)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 1,053 ms
コンパイル使用メモリ 54,552 KB
実行使用メモリ 52,512 KB
最終ジャッジ日時 2023-08-30 01:11:06
合計ジャッジ時間 13,554 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 626 ms
49,672 KB
testcase_01 AC 626 ms
51,456 KB
testcase_02 AC 627 ms
49,652 KB
testcase_03 AC 632 ms
50,188 KB
testcase_04 AC 637 ms
50,604 KB
testcase_05 AC 639 ms
50,340 KB
testcase_06 AC 630 ms
51,928 KB
testcase_07 AC 626 ms
50,412 KB
testcase_08 AC 628 ms
50,396 KB
testcase_09 AC 639 ms
50,300 KB
testcase_10 AC 625 ms
50,608 KB
testcase_11 AC 622 ms
49,840 KB
testcase_12 AC 624 ms
49,600 KB
testcase_13 AC 639 ms
49,856 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  
  def main do
    [n, k] = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)
    an = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)
    solve(n, k, an) |> IO.puts()
  end

  def solve(n, k, an) when 1 <= k and k <= n and n <= 100 do
    an |> Enum.reject(&(&1 < 1)) |> Enum.sort(&(&1 > &2)) |> Stream.take(k) |> Enum.reduce(0, &(&1 + &2))
  end

end
0