結果
問題 | No.1338 Giant Class |
ユーザー |
![]() |
提出日時 | 2021-01-15 21:58:52 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 1,641 ms / 2,000 ms |
コード長 | 1,216 bytes |
コンパイル時間 | 13,787 ms |
コンパイル使用メモリ | 456,064 KB |
実行使用メモリ | 106,824 KB |
最終ジャッジ日時 | 2024-11-26 14:39:00 |
合計ジャッジ時間 | 39,002 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
package yukicoderimport 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() * Wrepeat(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 + 1map[X] = Y}println(ans)}}}}/** 確保するメモリの大きさ(単位: MB) */private const val MEMORY: Long = 64fun main(args: Array<String>) {Thread.setDefaultUncaughtExceptionHandler { _: Thread?, e: Throwable ->e.printStackTrace()System.exit(1)}Thread(null, Main(args = args), "", MEMORY * 1048576L).start()}