結果

問題 No.1389 Clumsy Calculation
ユーザー 👑 箱
提出日時 2021-02-12 21:29:50
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 504 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 16,393 ms
コンパイル使用メモリ 418,176 KB
実行使用メモリ 67,688 KB
最終ジャッジ日時 2023-09-27 02:56:19
合計ジャッジ時間 31,109 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 293 ms
53,732 KB
testcase_01 AC 297 ms
53,668 KB
testcase_02 AC 293 ms
53,656 KB
testcase_03 AC 319 ms
56,040 KB
testcase_04 AC 317 ms
55,984 KB
testcase_05 AC 318 ms
53,808 KB
testcase_06 AC 319 ms
55,952 KB
testcase_07 AC 319 ms
55,948 KB
testcase_08 AC 292 ms
54,072 KB
testcase_09 AC 503 ms
67,688 KB
testcase_10 AC 450 ms
59,588 KB
testcase_11 AC 312 ms
55,976 KB
testcase_12 AC 310 ms
55,892 KB
testcase_13 AC 305 ms
53,992 KB
testcase_14 AC 500 ms
63,552 KB
testcase_15 AC 495 ms
63,744 KB
testcase_16 AC 502 ms
63,852 KB
testcase_17 AC 498 ms
63,416 KB
testcase_18 AC 494 ms
63,688 KB
testcase_19 AC 499 ms
63,468 KB
testcase_20 AC 498 ms
63,644 KB
testcase_21 AC 501 ms
63,832 KB
testcase_22 AC 497 ms
63,576 KB
testcase_23 AC 496 ms
63,928 KB
testcase_24 AC 504 ms
63,736 KB
testcase_25 AC 496 ms
63,700 KB
testcase_26 AC 493 ms
63,576 KB
testcase_27 AC 494 ms
63,728 KB
testcase_28 AC 500 ms
63,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve() {
    val n = nextInt()
    val x = nextLong()
    val s = Array(n) { nextLong() }
    val sum = s.sum()
    for (i in 0 until n) {
        if (s[i] % 2 != 0L) continue
        val v = sum - s[i] / 2
        if ((n - 1) * x == v) {
            println(s[i] / 2)
            return
        }
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

// 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