結果

問題 No.633 バスの運賃
ユーザー 💕💖💞💕💖💞
提出日時 2018-03-07 13:36:21
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 295 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 15,301 ms
コンパイル使用メモリ 440,000 KB
実行使用メモリ 57,204 KB
最終ジャッジ日時 2024-04-30 17:08:18
合計ジャッジ時間 14,616 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 268 ms
57,068 KB
testcase_01 AC 279 ms
56,912 KB
testcase_02 AC 272 ms
57,204 KB
testcase_03 AC 277 ms
57,164 KB
testcase_04 AC 295 ms
57,136 KB
testcase_05 AC 279 ms
57,032 KB
testcase_06 AC 270 ms
56,916 KB
testcase_07 AC 273 ms
57,108 KB
testcase_08 AC 280 ms
57,068 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:2:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
         ^
Main.kt:12:30: warning: name shadowed: money
  (1..n).zip(money) { index, money ->
                             ^

ソースコード

diff #

data class Person(val step:Int, var charge:Int)
fun main(args:Array<String>) {

  val n = readLine()!!.toInt()

  val money = (1..n-1).map { readLine()!!.toInt() }.toMutableList()
  money.add(0)

  val buff = mutableListOf<Person>()

  var charges = 0
  (1..n).zip(money) { index, money ->
    val (down, up) = readLine()!!.split(" ").map { it.toInt() }
    //println("moeny ${index} ${money}")
    // add persons
    (1..up).map {
      buff.add( Person(index, 0) )
    }
    // remove persons
    (1..down).map {
      val head = buff[0]
      charges += head.charge
      buff.removeAt(0)
    }

    // charge all persons
    for( person in buff ) {
      person.charge += money
    }
    //println( buff )
    //println(charges)
  }
  println(charges)
}
0