Submission #51574795


Source Code Expand

fun main() {
    val (n, k) = readln().split(" ").map { it.toLong() }
    val a = readln().split(" ").map { it.toLong() }
        .distinct()

    var ans = sum(1, k)

    for(i in a.indices) {
        if(a[i] <= k) {
            ans -= a[i]
        }
    }

    println(ans)
}

fun sum(start: Long, end: Long): Long {
    return if((start + end - 1) % 2 == 0L) {
        (start + end) * ((end - start + 1) / 2)
    } else {
        val dEnd = end - 1
        (start + dEnd) * ((dEnd - start + 1) / 2) + end
    }
}

Submission Info

Submission Time
Task C - Σ
User dhirabayashi
Language Kotlin (Kotlin/JVM 1.8.20)
Score 250
Code Size 540 Byte
Status AC
Exec Time 389 ms
Memory 83044 KiB

Compile Error

Main.kt:2:10: warning: variable 'n' is never used
    val (n, k) = readln().split(" ").map { it.toLong() }
         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 3
AC × 22
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 59 ms 39732 KiB
00_sample_01.txt AC 60 ms 39840 KiB
00_sample_02.txt AC 61 ms 39748 KiB
01_random_00.txt AC 341 ms 66440 KiB
01_random_01.txt AC 374 ms 76404 KiB
01_random_02.txt AC 385 ms 82424 KiB
01_random_03.txt AC 349 ms 76372 KiB
01_random_04.txt AC 219 ms 51344 KiB
01_random_05.txt AC 366 ms 76248 KiB
01_random_06.txt AC 327 ms 66368 KiB
01_random_07.txt AC 389 ms 76632 KiB
01_random_08.txt AC 305 ms 65848 KiB
01_random_09.txt AC 367 ms 76276 KiB
01_random_10.txt AC 319 ms 62776 KiB
01_random_11.txt AC 379 ms 82396 KiB
02_random2_00.txt AC 389 ms 75868 KiB
02_random2_01.txt AC 370 ms 75964 KiB
02_random2_02.txt AC 366 ms 76232 KiB
03_handmade_00.txt AC 319 ms 66624 KiB
03_handmade_01.txt AC 317 ms 66912 KiB
03_handmade_02.txt AC 311 ms 77876 KiB
03_handmade_03.txt AC 333 ms 83044 KiB