結果

問題 No.1687 What the Heck?
ユーザー 👑 箱
提出日時 2021-09-24 21:59:41
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 900 bytes
コンパイル時間 13,180 ms
コンパイル使用メモリ 426,816 KB
実行使用メモリ 65,488 KB
最終ジャッジ日時 2023-09-18 21:21:12
合計ジャッジ時間 22,838 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
55,672 KB
testcase_01 AC 294 ms
55,968 KB
testcase_02 AC 295 ms
55,692 KB
testcase_03 AC 296 ms
53,704 KB
testcase_04 AC 296 ms
55,624 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 469 ms
58,040 KB
testcase_10 AC 452 ms
57,500 KB
testcase_11 AC 456 ms
59,628 KB
testcase_12 AC 491 ms
63,624 KB
testcase_13 AC 486 ms
61,404 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val a = Array(n) { nextInt() }
    val idx = a.indexOf(n) + 1
    println(max(0, n * (n + 1L) / 2 - idx * 2))
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", 1.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