結果
| 問題 |
No.709 優勝可能性
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2022-10-19 10:11:49 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 642 ms / 3,500 ms |
| コード長 | 2,066 bytes |
| コンパイル時間 | 2,192 ms |
| コンパイル使用メモリ | 79,312 KB |
| 実行使用メモリ | 95,412 KB |
| 最終ジャッジ日時 | 2024-06-29 13:38:25 |
| 合計ジャッジ時間 | 9,565 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
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<>());
}
int[] counts = new int[n];
int ans = 0;
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) {
for (int y : tops.get(j)) {
counts[y]--;
if (counts[y] == 0) {
ans--;
}
}
tops.get(j).clear();
tops.get(j).add(i);
maxes[j] = x;
counts[i]++;
} else if (maxes[j] == x) {
tops.get(j).add(i);
counts[i]++;
}
}
if (counts[i] > 0) {
ans++;
}
sb.append(ans).append("\n");
}
System.out.print(sb);
}
}
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 String next() throws Exception {
while (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
}
tenten