結果

問題 No.709 優勝可能性
ユーザー 37zigen37zigen
提出日時 2018-06-29 23:09:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,090 ms / 3,500 ms
コード長 1,278 bytes
コンパイル時間 2,361 ms
コンパイル使用メモリ 76,960 KB
実行使用メモリ 106,624 KB
最終ジャッジ日時 2023-09-13 15:37:59
合計ジャッジ時間 23,383 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
56,060 KB
testcase_01 AC 130 ms
55,616 KB
testcase_02 AC 133 ms
55,620 KB
testcase_03 AC 132 ms
55,792 KB
testcase_04 AC 127 ms
55,724 KB
testcase_05 AC 130 ms
55,844 KB
testcase_06 AC 134 ms
55,768 KB
testcase_07 AC 126 ms
55,856 KB
testcase_08 AC 134 ms
55,612 KB
testcase_09 AC 133 ms
55,380 KB
testcase_10 AC 1,180 ms
72,584 KB
testcase_11 AC 844 ms
67,616 KB
testcase_12 AC 2,019 ms
76,472 KB
testcase_13 AC 1,824 ms
79,336 KB
testcase_14 AC 1,789 ms
77,096 KB
testcase_15 AC 1,838 ms
76,840 KB
testcase_16 AC 2,090 ms
81,832 KB
testcase_17 AC 2,069 ms
106,624 KB
testcase_18 AC 125 ms
55,872 KB
testcase_19 AC 134 ms
55,544 KB
testcase_20 AC 1,959 ms
74,424 KB
testcase_21 AC 1,982 ms
74,396 KB
testcase_22 AC 126 ms
55,728 KB
testcase_23 AC 127 ms
56,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] R = new int[N][M];
		PriorityQueue<Long>[] pqs = new PriorityQueue[M];
		for (int i = 0; i < pqs.length; ++i) {
			pqs[i] = new PriorityQueue<>();
		}
		int[] curVal = new int[M];
		int[] vanish = new int[N];
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < M; ++j) {
				R[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < M; ++j) {
				curVal[j] = Math.max(curVal[j], R[i][j]);
				pqs[j].add((long) R[i][j] << 32 | i);
			}
			++ans;
			for (int j = 0; j < M; ++j) {
				while (!pqs[j].isEmpty() && (pqs[j].peek() >> 32) < curVal[j]) {
					int idx = pqs[j].poll().intValue();
					++vanish[idx];
					if (vanish[idx] == M) {
						--ans;
					}
				}
			}
			pw.println(ans);
		}
		pw.close();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0