結果
| 問題 | No.1374 Absolute Game |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-24 11:52:36 |
| 言語 | Kotlin (2.3.20) |
| 結果 |
AC
|
| 実行時間 | 450 ms / 2,000 ms |
| + 195µs | |
| コード長 | 375 bytes |
| 記録 | |
| コンパイル時間 | 7,742 ms |
| コンパイル使用メモリ | 514,948 KB |
| 実行使用メモリ | 77,364 KB |
| 最終ジャッジ日時 | 2026-08-18 19:22:08 |
| 合計ジャッジ時間 | 19,599 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 |
ソースコード
import kotlin.math.abs
// editorial
fun main() {
val n = readLine()!!.toInt()
var a = readLine()!!.split(" ").map { it.toLong() }
if (a.sum() < 0) {
a = a.map { -it }
}
a = a.sortedDescending()
var (x, y) = listOf(0L, 0L)
for (i in a.indices) {
if (i % 2 == 0) x += a[i]
else y += a[i]
}
println(abs(x) - abs(y))
}