結果

問題 No.1416 ショッピングモール
ユーザー 👑 yumechiyumechi
提出日時 2021-03-07 06:00:14
言語 Scala(Beta)
(3.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 531 bytes
コンパイル時間 8,949 ms
コンパイル使用メモリ 258,344 KB
実行使用メモリ 79,240 KB
最終ジャッジ日時 2024-04-17 08:17:05
合計ジャッジ時間 37,397 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 940 ms
65,108 KB
testcase_01 AC 945 ms
64,828 KB
testcase_02 AC 937 ms
64,892 KB
testcase_03 AC 947 ms
64,688 KB
testcase_04 AC 938 ms
64,728 KB
testcase_05 TLE -
testcase_06 AC 956 ms
64,856 KB
testcase_07 AC 991 ms
65,248 KB
testcase_08 TLE -
testcase_09 AC 950 ms
64,592 KB
testcase_10 AC 961 ms
65,132 KB
testcase_11 TLE -
testcase_12 AC 999 ms
65,360 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner

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

  def solve(n: Int, an: Array[Int]): BigInt = {
    var cost: BigInt = 0
    var mlin: Int = 0
    for(i <- 0 to 15) {
      val mxlin = math.pow (2, i).toInt
      val e = an.slice(mlin, math.min(mlin + mxlin, n))
      cost += e.sum * i
      if (mxlin >= n) {
        return cost
      }
      mlin = mlin + mxlin
    }
    cost
  }

  val n = sc.nextInt
  val an = Array.fill(n)(sc.nextInt).sortBy((i: Int) => -i)
  println(solve(n, an))
}
0