結果

問題 No.999 てん vs. ほむ
ユーザー 👑 箱
提出日時 2020-02-28 21:26:00
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 641 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 16,616 ms
コンパイル使用メモリ 416,416 KB
実行使用メモリ 74,016 KB
最終ジャッジ日時 2023-08-03 19:32:12
合計ジャッジ時間 30,345 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 298 ms
52,804 KB
testcase_01 AC 296 ms
52,796 KB
testcase_02 AC 289 ms
52,756 KB
testcase_03 AC 300 ms
52,740 KB
testcase_04 AC 298 ms
52,636 KB
testcase_05 AC 306 ms
52,772 KB
testcase_06 AC 303 ms
52,736 KB
testcase_07 AC 303 ms
52,764 KB
testcase_08 AC 403 ms
53,484 KB
testcase_09 AC 636 ms
70,736 KB
testcase_10 AC 484 ms
57,636 KB
testcase_11 AC 463 ms
57,776 KB
testcase_12 AC 511 ms
63,872 KB
testcase_13 AC 634 ms
70,468 KB
testcase_14 AC 630 ms
70,456 KB
testcase_15 AC 634 ms
70,364 KB
testcase_16 AC 640 ms
70,452 KB
testcase_17 AC 580 ms
72,132 KB
testcase_18 AC 583 ms
74,016 KB
testcase_19 AC 592 ms
72,172 KB
testcase_20 AC 586 ms
72,124 KB
testcase_21 AC 641 ms
70,544 KB
testcase_22 AC 636 ms
70,400 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