結果

問題 No.370 道路の掃除
ユーザー 💕💖💞💕💖💞
提出日時 2017-07-01 14:19:26
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 13,413 ms
コンパイル使用メモリ 442,936 KB
実行使用メモリ 91,800 KB
最終ジャッジ日時 2024-04-30 15:12:33
合計ジャッジ時間 29,481 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 344 ms
60,476 KB
testcase_03 AC 349 ms
60,328 KB
testcase_04 AC 346 ms
60,444 KB
testcase_05 AC 351 ms
60,508 KB
testcase_06 AC 357 ms
60,472 KB
testcase_07 AC 346 ms
60,332 KB
testcase_08 AC 345 ms
60,500 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 356 ms
60,564 KB
testcase_13 WA -
testcase_14 AC 369 ms
60,520 KB
testcase_15 WA -
testcase_16 AC 369 ms
60,528 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:2:11: warning: parameter 'args' is never used
fun main( args : Array<String> ) {
          ^

ソースコード

diff #

import java.lang.Math
fun main( args : Array<String> ) {
  val (n, m) = readLine()!!.split(" ").map { it.toInt() }
  var ps = (1..m).map {
    readLine()!!.toInt()
  }.toList()
  var status = 0
  var miles  = 0
  (0..n-1).map {
    val f = ps.map { x -> 
                       Pair(x, Math.abs(x - status) ) 
                    }.sortedBy { x->
                      x.second 
                    }.first()
    miles   += f.second
    status   = f.first
    ps = ps.filter { x -> x != status }
  }
  println( miles )
}
0