結果

問題 No.2154 あさかつの参加人数
ユーザー 👑 箱
提出日時 2022-12-09 21:35:47
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 995 ms / 2,000 ms
コード長 1,184 bytes
コンパイル時間 16,220 ms
コンパイル使用メモリ 418,608 KB
実行使用メモリ 85,988 KB
最終ジャッジ日時 2023-08-04 22:49:06
合計ジャッジ時間 42,482 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 970 ms
85,300 KB
testcase_01 AC 964 ms
85,664 KB
testcase_02 AC 995 ms
85,484 KB
testcase_03 AC 990 ms
85,988 KB
testcase_04 AC 980 ms
85,440 KB
testcase_05 AC 681 ms
58,816 KB
testcase_06 AC 900 ms
69,172 KB
testcase_07 AC 881 ms
75,240 KB
testcase_08 AC 879 ms
77,392 KB
testcase_09 AC 622 ms
70,608 KB
testcase_10 AC 875 ms
75,280 KB
testcase_11 AC 978 ms
82,008 KB
testcase_12 AC 906 ms
73,084 KB
testcase_13 AC 758 ms
63,156 KB
testcase_14 AC 903 ms
71,908 KB
testcase_15 AC 843 ms
73,560 KB
testcase_16 AC 900 ms
75,724 KB
testcase_17 AC 775 ms
75,000 KB
testcase_18 AC 899 ms
75,968 KB
testcase_19 AC 512 ms
58,776 KB
testcase_20 AC 901 ms
79,392 KB
testcase_21 AC 639 ms
67,032 KB
testcase_22 AC 778 ms
81,976 KB
testcase_23 AC 958 ms
82,048 KB
testcase_24 AC 957 ms
84,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val m = nextInt()
    val a = Array(n) { 0L }
    for (i in 0 until m) {
        val l = nextInt()
        val r = nextInt()
        a[n - r]++
        if (l != n) {
            a[n - l - 1]--
        }
    }
    val ans = mutableListOf<Long>()
    var now = 0L
    for (i in n - 1 downTo 0) {
        now += a[i]
        ans.add(now)
    }
    println(ans.reversed().joinToString("\n"))
}

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