結果
問題 | No.709 優勝可能性 |
ユーザー |
![]() |
提出日時 | 2020-12-28 14:21:12 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,983 ms / 3,500 ms |
コード長 | 1,373 bytes |
コンパイル時間 | 1,940 ms |
コンパイル使用メモリ | 80,420 KB |
実行使用メモリ | 126,296 KB |
最終ジャッジ日時 | 2024-10-03 04:40:45 |
合計ジャッジ時間 | 18,730 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
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);}}