結果

問題 No.1338 Giant Class
ユーザー tentententen
提出日時 2023-08-03 12:54:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 470 ms / 2,000 ms
コード長 2,115 bytes
コンパイル時間 2,735 ms
コンパイル使用メモリ 92,264 KB
実行使用メモリ 60,528 KB
最終ジャッジ日時 2024-04-21 10:45:49
合計ジャッジ時間 11,621 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
36,680 KB
testcase_01 AC 47 ms
37,032 KB
testcase_02 AC 350 ms
49,112 KB
testcase_03 AC 48 ms
36,956 KB
testcase_04 AC 51 ms
36,904 KB
testcase_05 AC 57 ms
36,996 KB
testcase_06 AC 314 ms
53,108 KB
testcase_07 AC 423 ms
57,656 KB
testcase_08 AC 304 ms
52,816 KB
testcase_09 AC 309 ms
52,188 KB
testcase_10 AC 433 ms
57,888 KB
testcase_11 AC 151 ms
42,692 KB
testcase_12 AC 368 ms
51,860 KB
testcase_13 AC 329 ms
52,716 KB
testcase_14 AC 193 ms
45,888 KB
testcase_15 AC 226 ms
47,452 KB
testcase_16 AC 153 ms
42,316 KB
testcase_17 AC 325 ms
52,796 KB
testcase_18 AC 189 ms
44,344 KB
testcase_19 AC 238 ms
47,016 KB
testcase_20 AC 459 ms
60,528 KB
testcase_21 AC 455 ms
60,224 KB
testcase_22 AC 470 ms
60,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int h = sc.nextInt();
        int w = sc.nextInt();
        HashMap<Integer, Integer> places = new HashMap<>();
        int q = sc.nextInt();
        long total = (long)h * w;
        StringBuilder sb = new StringBuilder();
        while (q-- > 0) {
            int r = sc.nextInt();
            int c = sc.nextInt();
            if (places.containsKey(c)) {
                if (places.get(c) > r) {
                    total -= places.get(c) - r;
                    places.put(c, r);
                }
            } else {
                total -= h + 1 - r;
                places.put(c, r);
            }
            sb.append(total).append("\n");
        }
        System.out.print(sb);
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0