結果

問題 No.999 てん vs. ほむ
ユーザー 👑 箱星箱星
提出日時 2020-02-28 21:26:00
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 680 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 14,843 ms
コンパイル使用メモリ 434,516 KB
実行使用メモリ 78,488 KB
最終ジャッジ日時 2024-04-21 17:47:51
合計ジャッジ時間 28,430 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 335 ms
51,860 KB
testcase_01 AC 325 ms
51,672 KB
testcase_02 AC 331 ms
51,788 KB
testcase_03 AC 341 ms
51,836 KB
testcase_04 AC 335 ms
51,660 KB
testcase_05 AC 339 ms
51,876 KB
testcase_06 AC 340 ms
51,716 KB
testcase_07 AC 339 ms
51,788 KB
testcase_08 AC 448 ms
52,856 KB
testcase_09 AC 636 ms
76,808 KB
testcase_10 AC 532 ms
60,912 KB
testcase_11 AC 518 ms
58,860 KB
testcase_12 AC 550 ms
64,560 KB
testcase_13 AC 637 ms
78,320 KB
testcase_14 AC 636 ms
78,096 KB
testcase_15 AC 680 ms
78,260 KB
testcase_16 AC 656 ms
78,488 KB
testcase_17 AC 610 ms
72,716 KB
testcase_18 AC 604 ms
72,624 KB
testcase_19 AC 610 ms
72,640 KB
testcase_20 AC 612 ms
72,616 KB
testcase_21 AC 637 ms
77,972 KB
testcase_22 AC 639 ms
77,604 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }
    var hom = 0L
    var tem = 0L
    for (i in 0 until n) {
        hom += a[2 * i + 1]
        tem += a[2 * i]
    }
    var max = hom - tem
    for (i in 0 until n) {
        hom += a[2 * i] - a[2 * i + 1]
        tem += a[2 * i + 1] - a[2 * i]
        max = Math.max(max, hom - tem)
    }
    println(max)
}
0