結果

問題 No.1374 Absolute Game
コンテスト
ユーザー face4
提出日時 2021-07-24 11:52:36
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 375 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12,110 ms
コンパイル使用メモリ 478,360 KB
実行使用メモリ 550,732 KB
最終ジャッジ日時 2026-04-02 17:26:24
合計ジャッジ時間 25,607 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 MLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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))
}
0