結果

問題 No.1823 Tricolor Dango
ユーザー 👑 箱
提出日時 2021-12-14 13:36:37
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 492 ms / 2,000 ms
コード長 1,194 bytes
コンパイル時間 15,713 ms
コンパイル使用メモリ 421,628 KB
実行使用メモリ 63,836 KB
最終ジャッジ日時 2023-08-09 04:04:27
合計ジャッジ時間 29,460 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 279 ms
55,948 KB
testcase_01 AC 492 ms
59,780 KB
testcase_02 AC 481 ms
59,568 KB
testcase_03 AC 480 ms
57,880 KB
testcase_04 AC 476 ms
58,716 KB
testcase_05 AC 463 ms
58,200 KB
testcase_06 AC 470 ms
58,432 KB
testcase_07 AC 473 ms
58,396 KB
testcase_08 AC 464 ms
58,532 KB
testcase_09 AC 483 ms
58,384 KB
testcase_10 AC 490 ms
60,136 KB
testcase_11 AC 476 ms
58,696 KB
testcase_12 AC 455 ms
60,400 KB
testcase_13 AC 462 ms
58,452 KB
testcase_14 AC 469 ms
58,368 KB
testcase_15 AC 485 ms
58,524 KB
testcase_16 AC 412 ms
57,748 KB
testcase_17 AC 409 ms
59,488 KB
testcase_18 AC 434 ms
61,628 KB
testcase_19 AC 485 ms
63,836 KB
testcase_20 AC 438 ms
61,552 KB
testcase_21 AC 484 ms
58,464 KB
testcase_22 AC 489 ms
57,892 KB
testcase_23 AC 487 ms
60,232 KB
testcase_24 AC 480 ms
58,400 KB
testcase_25 AC 477 ms
59,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val numCases = nextInt()
    case@ for (_i in 0 until numCases) {
        val n = nextInt()
        val a = Array(n) { nextLong() }
        val sum = a.sum()
        if (sum % 3L != 0L) {
            println("No")
        } else {
            val max = a.maxOrNull()!!
            if (2 * max > sum - max) {
                println("No")
            } else {
                println("Yes")
            }
        }
    }
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", abs(1L.shl(26)))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0