結果

問題 No.1046 Fruits Rush
ユーザー 👑 yumechiyumechi
提出日時 2021-02-18 02:59:37
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,013 ms / 2,000 ms
コード長 291 bytes
コンパイル時間 9,109 ms
コンパイル使用メモリ 268,812 KB
実行使用メモリ 64,160 KB
最終ジャッジ日時 2023-10-12 12:47:27
合計ジャッジ時間 27,984 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,000 ms
63,688 KB
testcase_01 AC 992 ms
64,116 KB
testcase_02 AC 979 ms
63,712 KB
testcase_03 AC 1,005 ms
63,656 KB
testcase_04 AC 1,013 ms
63,692 KB
testcase_05 AC 1,013 ms
63,872 KB
testcase_06 AC 989 ms
63,640 KB
testcase_07 AC 996 ms
63,684 KB
testcase_08 AC 1,001 ms
63,600 KB
testcase_09 AC 1,009 ms
63,884 KB
testcase_10 AC 997 ms
63,628 KB
testcase_11 AC 1,010 ms
63,580 KB
testcase_12 AC 1,000 ms
64,160 KB
testcase_13 AC 995 ms
63,844 KB
testcase_14 AC 973 ms
63,484 KB
testcase_15 AC 980 ms
63,580 KB
testcase_16 AC 984 ms
63,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val k = sc.nextInt
  println(Array.fill(n)(sc.nextInt).sorted.reverse.splitAt(k)._1 match {
    case t @ Array(m, _*) => if (m > 0) t.filter(_ > 0).sum else m
    case _ => 0
  })
}
0