結果

問題 No.709 優勝可能性
ユーザー tenten
提出日時 2022-08-12 08:38:47
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 1,754 bytes
コンパイル時間 2,781 ms
コンパイル使用メモリ 79,216 KB
実行使用メモリ 68,084 KB
最終ジャッジ日時 2024-09-22 12:52:24
合計ジャッジ時間 10,734 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other AC * 10 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
        ArrayList<ArrayList<Integer>> probables = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            probables.add(new ArrayList<>());
        }
        int[] maxes = new int[m];
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < n; j++) {
            HashSet<Integer> counts = new HashSet<>();
            for (int i = 0; i < m; i++) {
                int x = sc.nextInt();
                if (maxes[i] < x) {
                    probables.get(i).clear();
                    probables.get(i).add(j);
                    maxes[i] = x;
                } else if (maxes[i] == x) {
                    probables.get(i).add(j);
                }
                counts.addAll(probables.get(i));
            }
            sb.append(counts.size()).append("\n");
        }
        System.out.print(sb);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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();
    }
}
0