結果

問題 No.1338 Giant Class
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-01-15 21:58:52
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,710 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 16,533 ms
コンパイル使用メモリ 424,164 KB
実行使用メモリ 72,912 KB
最終ジャッジ日時 2023-08-17 17:04:15
合計ジャッジ時間 42,615 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 346 ms
53,940 KB
testcase_01 AC 348 ms
53,912 KB
testcase_02 AC 1,460 ms
65,056 KB
testcase_03 AC 372 ms
53,868 KB
testcase_04 AC 423 ms
56,216 KB
testcase_05 AC 458 ms
56,500 KB
testcase_06 AC 1,343 ms
66,804 KB
testcase_07 AC 1,590 ms
71,012 KB
testcase_08 AC 1,202 ms
67,608 KB
testcase_09 AC 1,253 ms
66,852 KB
testcase_10 AC 1,625 ms
71,348 KB
testcase_11 AC 656 ms
57,988 KB
testcase_12 AC 1,410 ms
67,176 KB
testcase_13 AC 1,248 ms
66,976 KB
testcase_14 AC 743 ms
60,220 KB
testcase_15 AC 855 ms
65,408 KB
testcase_16 AC 663 ms
60,572 KB
testcase_17 AC 1,269 ms
66,708 KB
testcase_18 AC 767 ms
58,348 KB
testcase_19 AC 912 ms
66,524 KB
testcase_20 AC 1,670 ms
71,180 KB
testcase_21 AC 1,606 ms
72,912 KB
testcase_22 AC 1,710 ms
71,204 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