結果

問題 No.1046 Fruits Rush
ユーザー 👑 yumechiyumechi
提出日時 2021-02-18 02:57:23
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 999 ms / 2,000 ms
コード長 346 bytes
コンパイル時間 10,273 ms
コンパイル使用メモリ 249,092 KB
実行使用メモリ 64,256 KB
最終ジャッジ日時 2023-10-12 12:44:01
合計ジャッジ時間 28,791 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 981 ms
63,624 KB
testcase_01 AC 980 ms
63,640 KB
testcase_02 AC 967 ms
63,560 KB
testcase_03 AC 984 ms
63,620 KB
testcase_04 AC 991 ms
63,564 KB
testcase_05 AC 999 ms
64,256 KB
testcase_06 AC 983 ms
64,040 KB
testcase_07 AC 985 ms
63,732 KB
testcase_08 AC 987 ms
63,776 KB
testcase_09 AC 987 ms
63,488 KB
testcase_10 AC 981 ms
63,552 KB
testcase_11 AC 982 ms
63,564 KB
testcase_12 AC 991 ms
63,668 KB
testcase_13 AC 992 ms
63,748 KB
testcase_14 AC 969 ms
63,444 KB
testcase_15 AC 982 ms
63,728 KB
testcase_16 AC 977 ms
63,472 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, _*) => m + ((m > 0) match {
      case true => t.filter(_ > 0).sum - m
      case false => 0
    })
    case _ => 0
  })
}
0