結果

問題 No.709 優勝可能性
ユーザー tentententen
提出日時 2022-08-12 08:44:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 602 ms / 3,500 ms
コード長 2,181 bytes
コンパイル時間 2,845 ms
コンパイル使用メモリ 79,432 KB
実行使用メモリ 84,124 KB
最終ジャッジ日時 2023-10-23 19:12:32
合計ジャッジ時間 10,550 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,452 KB
testcase_01 AC 53 ms
51,556 KB
testcase_02 AC 54 ms
53,456 KB
testcase_03 AC 54 ms
51,584 KB
testcase_04 AC 54 ms
53,456 KB
testcase_05 AC 54 ms
53,456 KB
testcase_06 AC 53 ms
53,456 KB
testcase_07 AC 53 ms
53,452 KB
testcase_08 AC 52 ms
53,456 KB
testcase_09 AC 54 ms
52,528 KB
testcase_10 AC 346 ms
62,612 KB
testcase_11 AC 253 ms
60,580 KB
testcase_12 AC 470 ms
62,168 KB
testcase_13 AC 469 ms
63,856 KB
testcase_14 AC 429 ms
63,064 KB
testcase_15 AC 455 ms
63,248 KB
testcase_16 AC 467 ms
67,192 KB
testcase_17 AC 602 ms
84,124 KB
testcase_18 AC 54 ms
53,456 KB
testcase_19 AC 55 ms
53,456 KB
testcase_20 AC 524 ms
62,856 KB
testcase_21 AC 523 ms
62,724 KB
testcase_22 AC 52 ms
53,456 KB
testcase_23 AC 52 ms
53,456 KB
権限があれば一括ダウンロードができます

ソースコード

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();
        int[] prizes = new int[n];
        int count = 0;
        for (int j = 0; j < n; j++) {
            for (int i = 0; i < m; i++) {
                int x = sc.nextInt();
                if (maxes[i] < x) {
                    for (int y : probables.get(i)) {
                        prizes[y]--;
                        if (prizes[y] == 0) {
                            count--;
                        }
                    }
                    probables.get(i).clear();
                    probables.get(i).add(j);
                    maxes[i] = x;
                    if (prizes[j] == 0) {
                        count++;
                    }
                    prizes[j]++;
                } else if (maxes[i] == x) {
                    probables.get(i).add(j);
                    if (prizes[j] == 0) {
                        count++;
                    }
                    prizes[j]++;
                }
            }
            sb.append(count).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