結果
問題 |
No.709 優勝可能性
|
ユーザー |
![]() |
提出日時 | 2020-01-29 09:11:18 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 865 ms / 3,500 ms |
コード長 | 1,664 bytes |
コンパイル時間 | 2,331 ms |
コンパイル使用メモリ | 78,372 KB |
実行使用メモリ | 98,480 KB |
最終ジャッジ日時 | 2024-09-15 20:08:13 |
合計ジャッジ時間 | 12,336 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int m = Integer.parseInt(first[1]); HashSet<Integer>[] maxIdxes = new HashSet[m]; int[] counts = new int[n]; for (int i = 0; i < m; i++) { maxIdxes[i] = new HashSet<Integer>(); } int ans = 0; int[] maxValues = new int[m]; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { String[] line = br.readLine().split(" ", m); for (int j = 0; j < m; j++) { int x = Integer.parseInt(line[j]); if (maxValues[j] < x) { maxValues[j] = x; for (int y : maxIdxes[j]) { counts[y]--; if (counts[y] == 0) { ans--; } } maxIdxes[j].clear(); maxIdxes[j].add(i); counts[i]++; if (counts[i] == 1) { ans++; } } else if (maxValues[j] == x) { maxIdxes[j].add(i); counts[i]++; if (counts[i] == 1) { ans++; } } } sb.append(ans).append("\n"); } System.out.print(sb); } }