結果
| 問題 |
No.709 優勝可能性
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-29 23:09:30 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,989 ms / 3,500 ms |
| コード長 | 1,278 bytes |
| コンパイル時間 | 2,197 ms |
| コンパイル使用メモリ | 79,672 KB |
| 実行使用メモリ | 104,336 KB |
| 最終ジャッジ日時 | 2024-07-01 00:13:04 |
| 合計ジャッジ時間 | 23,728 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
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));
}
}