結果

問題 No.709 優勝可能性
ユーザー tentententen
提出日時 2020-12-28 14:21:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,225 ms / 3,500 ms
コード長 1,373 bytes
コンパイル時間 2,424 ms
コンパイル使用メモリ 80,208 KB
実行使用メモリ 131,476 KB
最終ジャッジ日時 2024-04-14 07:28:21
合計ジャッジ時間 22,691 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
54,300 KB
testcase_01 AC 145 ms
54,276 KB
testcase_02 AC 142 ms
54,308 KB
testcase_03 AC 140 ms
54,372 KB
testcase_04 AC 135 ms
54,244 KB
testcase_05 AC 122 ms
53,152 KB
testcase_06 AC 144 ms
53,956 KB
testcase_07 AC 134 ms
54,468 KB
testcase_08 AC 138 ms
54,224 KB
testcase_09 AC 142 ms
54,076 KB
testcase_10 AC 1,111 ms
69,432 KB
testcase_11 AC 719 ms
59,656 KB
testcase_12 AC 1,640 ms
69,836 KB
testcase_13 AC 1,940 ms
78,156 KB
testcase_14 AC 1,832 ms
75,940 KB
testcase_15 AC 1,682 ms
77,316 KB
testcase_16 AC 1,891 ms
84,956 KB
testcase_17 AC 2,225 ms
131,476 KB
testcase_18 AC 130 ms
54,308 KB
testcase_19 AC 141 ms
54,360 KB
testcase_20 AC 1,764 ms
69,244 KB
testcase_21 AC 1,774 ms
68,908 KB
testcase_22 AC 121 ms
53,144 KB
testcase_23 AC 135 ms
54,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] maxes = new int[m];
        ArrayList<HashSet<Integer>> tops = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            tops.add(new HashSet<>());
        }
        HashMap<Integer, Integer> map = new HashMap<>();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
             for (int j = 0; j < m; j++) {
                int x = sc.nextInt();
                if (maxes[j] < x) {
                    maxes[j] = x;
                    for (int y : tops.get(j)) {
                        if (map.get(y) == 1) {
                            map.remove(y);
                        } else {
                            map.put(y, map.get(y) - 1);
                        }
                    }
                    tops.get(j).clear();
                    tops.get(j).add(i);
                    map.put(i, map.getOrDefault(i, 0) + 1);
                } else if (maxes[j] == x) {
                    tops.get(j).add(i);
                    map.put(i, map.getOrDefault(i, 0) + 1);
                }
            }
            sb.append(map.size()).append("\n");
        }
        System.out.print(sb);
    }
}
0