結果
問題 | No.370 道路の掃除 |
ユーザー |
![]() |
提出日時 | 2017-07-01 14:40:50 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 385 ms / 2,000 ms |
コード長 | 450 bytes |
コンパイル時間 | 13,392 ms |
コンパイル使用メモリ | 434,424 KB |
実行使用メモリ | 60,652 KB |
最終ジャッジ日時 | 2024-11-20 11:10:20 |
合計ジャッジ時間 | 26,810 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
Main.kt:1:11: warning: parameter 'args' is never used fun main( args : Array<String> ) { ^ Main.kt:14:8: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int ret!! ^
ソースコード
fun main( args : Array<String> ) { val (n, m) = readLine()!!.split(" ").map { it.toInt() } var ps = (1..m).map { readLine()!!.toInt() }.toList() .sorted() (0..m-n).map { i -> val a = ps[i] val b = ps[i+n-1] val ret = when { a*b < 0 -> listOf( Math.abs(a)*2 + Math.abs(b), Math.abs(a) + Math.abs(b)*2).min() else -> listOf( Math.abs(a), Math.abs(b) ).max() } ret!! }.min() .let { println( it ) } }