結果

問題 No.1338 Giant Class
ユーザー tentententen
提出日時 2021-01-18 09:51:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 853 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 72,648 KB
実行使用メモリ 77,456 KB
最終ジャッジ日時 2023-08-20 17:28:58
合計ジャッジ時間 17,389 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
56,308 KB
testcase_01 AC 103 ms
55,856 KB
testcase_02 AC 622 ms
66,992 KB
testcase_03 AC 119 ms
56,348 KB
testcase_04 AC 154 ms
56,196 KB
testcase_05 AC 155 ms
56,820 KB
testcase_06 AC 617 ms
69,352 KB
testcase_07 AC 717 ms
76,536 KB
testcase_08 AC 587 ms
67,960 KB
testcase_09 AC 578 ms
67,832 KB
testcase_10 AC 787 ms
77,456 KB
testcase_11 AC 278 ms
60,036 KB
testcase_12 AC 636 ms
71,308 KB
testcase_13 AC 586 ms
69,664 KB
testcase_14 AC 357 ms
60,468 KB
testcase_15 AC 409 ms
62,932 KB
testcase_16 AC 263 ms
59,920 KB
testcase_17 AC 598 ms
68,936 KB
testcase_18 AC 354 ms
60,992 KB
testcase_19 AC 499 ms
63,124 KB
testcase_20 AC 835 ms
75,108 KB
testcase_21 AC 853 ms
75,568 KB
testcase_22 AC 847 ms
75,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		long ans = (long)h * w;
		HashMap<Integer, Integer> places = new HashMap<>();
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int y = sc.nextInt();
		    int x = sc.nextInt();
		    if (places.containsKey(x)) {
		        if (places.get(x) > y) {
		            ans += y - places.get(x);
		            places.put(x, y);
		        }
		    } else {
		        ans += y - h - 1;
		        places.put(x, y);
		    }
		    sb.append(ans).append("\n");
		}
		System.out.print(sb);
	}
}
0