結果
問題 | No.1391 ±1 Abs Sum |
ユーザー | 👑 zeronosu77108 |
提出日時 | 2021-02-12 22:46:05 |
言語 | Kotlin (1.9.23) |
結果 |
WA
|
実行時間 | - |
コード長 | 725 bytes |
コンパイル時間 | 15,166 ms |
コンパイル使用メモリ | 429,428 KB |
実行使用メモリ | 57,256 KB |
最終ジャッジ日時 | 2023-09-27 05:39:57 |
合計ジャッジ時間 | 23,085 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 312 ms
57,256 KB |
testcase_01 | AC | 317 ms
57,116 KB |
testcase_02 | AC | 314 ms
57,140 KB |
testcase_03 | AC | 315 ms
57,168 KB |
testcase_04 | AC | 314 ms
57,216 KB |
testcase_05 | WA | - |
testcase_06 | AC | 315 ms
57,100 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
コンパイルメッセージ
Main.kt:9:9: warning: variable 'amin' is never used val amin = a.min()!! ^ Main.kt:9:23: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long val amin = a.min()!! ^ Main.kt:10:9: warning: variable 'amax' is never used val amax = a.max()!! ^ Main.kt:10:23: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long val amax = a.max()!! ^
ソースコード
import kotlin.collections.* import kotlin.math.* @kotlin.ExperimentalStdlibApi fun main() { val (n, k) = readLine()!!.split(" ").map { it.toInt() } val a = readLine()!!.split(" ").map { it.toLong() }.sorted() val amin = a.min()!! val amax = a.max()!! fun f(ai : Long) : Long { val l = a.map { abs(ai - it) }.toMutableList().sorted() return -l.sum() + l.take(k).sum() * 2 } var l = 0; var r = n - 1 while(l + 3 < r) { val ll = (l+l+r) / 3 val rr = (l+r+r) / 3 if (f(a[ll]) < f(a[rr])) l = ll else r = rr } var ans = minOf(f(a.first()), f(a.last())) for (i in l .. r) { ans = minOf(ans, f(a[i])) } println(ans) }