結果
問題 |
No.1338 Giant Class
|
ユーザー |
![]() |
提出日時 | 2021-01-18 09:51:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,147 ms / 2,000 ms |
コード長 | 705 bytes |
コンパイル時間 | 2,275 ms |
コンパイル使用メモリ | 76,012 KB |
実行使用メモリ | 71,944 KB |
最終ジャッジ日時 | 2024-11-30 20:57:09 |
合計ジャッジ時間 | 20,237 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
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); } }