結果

問題 No.2154 あさかつの参加人数
ユーザー 👑 箱星箱星
提出日時 2022-12-09 21:35:47
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 966 ms / 2,000 ms
コード長 1,184 bytes
コンパイル時間 16,065 ms
コンパイル使用メモリ 440,896 KB
実行使用メモリ 109,416 KB
最終ジャッジ日時 2024-04-22 21:08:57
合計ジャッジ時間 41,637 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 925 ms
108,040 KB
testcase_01 AC 952 ms
107,900 KB
testcase_02 AC 966 ms
108,032 KB
testcase_03 AC 941 ms
107,916 KB
testcase_04 AC 936 ms
108,044 KB
testcase_05 AC 662 ms
85,736 KB
testcase_06 AC 861 ms
90,316 KB
testcase_07 AC 810 ms
97,444 KB
testcase_08 AC 811 ms
99,776 KB
testcase_09 AC 692 ms
92,696 KB
testcase_10 AC 819 ms
96,832 KB
testcase_11 AC 900 ms
93,240 KB
testcase_12 AC 839 ms
98,564 KB
testcase_13 AC 737 ms
90,328 KB
testcase_14 AC 860 ms
96,096 KB
testcase_15 AC 830 ms
99,428 KB
testcase_16 AC 862 ms
98,144 KB
testcase_17 AC 860 ms
91,704 KB
testcase_18 AC 890 ms
90,584 KB
testcase_19 AC 547 ms
65,240 KB
testcase_20 AC 886 ms
101,380 KB
testcase_21 AC 684 ms
90,936 KB
testcase_22 AC 755 ms
95,696 KB
testcase_23 AC 907 ms
96,164 KB
testcase_24 AC 944 ms
109,416 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