結果

問題 No.1338 Giant Class
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-01-15 21:58:52
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,678 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 13,362 ms
コンパイル使用メモリ 450,168 KB
実行使用メモリ 103,224 KB
最終ジャッジ日時 2024-05-04 23:45:36
合計ジャッジ時間 38,603 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 318 ms
51,380 KB
testcase_01 AC 328 ms
51,320 KB
testcase_02 AC 1,395 ms
94,608 KB
testcase_03 AC 323 ms
51,552 KB
testcase_04 AC 374 ms
52,312 KB
testcase_05 AC 413 ms
52,772 KB
testcase_06 AC 1,269 ms
101,472 KB
testcase_07 AC 1,473 ms
103,224 KB
testcase_08 AC 1,164 ms
99,444 KB
testcase_09 AC 1,154 ms
98,336 KB
testcase_10 AC 1,558 ms
103,020 KB
testcase_11 AC 624 ms
70,252 KB
testcase_12 AC 1,426 ms
100,232 KB
testcase_13 AC 1,230 ms
99,560 KB
testcase_14 AC 811 ms
82,884 KB
testcase_15 AC 822 ms
89,212 KB
testcase_16 AC 618 ms
67,444 KB
testcase_17 AC 1,254 ms
101,248 KB
testcase_18 AC 781 ms
82,404 KB
testcase_19 AC 852 ms
88,256 KB
testcase_20 AC 1,647 ms
103,192 KB
testcase_21 AC 1,678 ms
102,492 KB
testcase_22 AC 1,598 ms
103,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder

import kotlin.math.*
import java.util.*

class Main(private val args : Array<String>) : Runnable {
    override fun run() {
        solve(args)
    }
    private fun solve(@Suppress("UNUSED_PARAMETER") args: Array<String>) {
        Scanner(System.`in`).use { sc ->
            val H = sc.nextInt()
            val W = sc.nextInt()
            val Q = sc.nextInt()
            val map = HashMap<Int, Int>()
            var ans = H.toLong() * W
            repeat(Q){
                val Y = sc.nextInt()
                val X = sc.nextInt()
                if (map.containsKey(X)) {
                    val v = map[X]!!
                    ans -= max(0, v - Y)
                    map[X] = min(v, Y)
                } else {
                    ans -= H - Y + 1
                    map[X] = Y
                }
                println(ans)
            }
        }
    }
}

/** 確保するメモリの大きさ(単位: MB)  */
private const val MEMORY: Long = 64

fun main(args: Array<String>) {
    Thread.setDefaultUncaughtExceptionHandler { _: Thread?, e: Throwable ->
        e.printStackTrace()
        System.exit(1)
    }
    Thread(null, Main(args = args), "", MEMORY * 1048576L).start()
}
0