結果

問題 No.709 優勝可能性
ユーザー ei1333333ei1333333
提出日時 2018-03-30 01:35:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,424 ms / 3,500 ms
コード長 892 bytes
コンパイル時間 3,686 ms
コンパイル使用メモリ 73,472 KB
実行使用メモリ 106,544 KB
最終ジャッジ日時 2023-09-08 07:02:20
合計ジャッジ時間 26,689 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,400 KB
testcase_01 AC 134 ms
55,892 KB
testcase_02 AC 131 ms
56,052 KB
testcase_03 AC 131 ms
55,828 KB
testcase_04 AC 124 ms
55,900 KB
testcase_05 AC 124 ms
55,728 KB
testcase_06 AC 125 ms
55,492 KB
testcase_07 AC 120 ms
56,384 KB
testcase_08 AC 125 ms
55,900 KB
testcase_09 AC 127 ms
55,348 KB
testcase_10 AC 1,286 ms
69,476 KB
testcase_11 AC 1,034 ms
67,856 KB
testcase_12 AC 1,923 ms
73,904 KB
testcase_13 AC 2,424 ms
106,544 KB
testcase_14 AC 2,113 ms
90,084 KB
testcase_15 AC 1,923 ms
88,908 KB
testcase_16 AC 2,031 ms
87,980 KB
testcase_17 AC 1,963 ms
82,372 KB
testcase_18 AC 116 ms
55,612 KB
testcase_19 AC 132 ms
55,944 KB
testcase_20 AC 2,160 ms
81,860 KB
testcase_21 AC 2,054 ms
81,952 KB
testcase_22 AC 124 ms
55,692 KB
testcase_23 AC 125 ms
55,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main
{
		public static void main(String arg[])
		{
				Scanner cin = new Scanner(System.in);
				int N = cin.nextInt();
				int M = cin.nextInt();
				int[][] R = new int[N][M];
				int[] last = new int[M];
				int[] deg = new int[N];
				int ans = 0;
			  
				for(int i = 0; i < N; i++) {
						for(int j = 0; j < M; j++) {
								R[i][j] = cin.nextInt();
								if(R[i][j] > R[last[j]][j]) {
										for(int k = last[j]; k < i; k++) {
												if(R[last[j]][j] == R[k][j]) {
														
														deg[k]--;
														if(deg[k] == 0) {
																ans--;
														}
												}
										}
										last[j] = i;
										deg[i]++;
										if(deg[i] == 1) ans++;
								} else if(R[i][j] == R[last[j]][j]) {
										deg[i]++;
										if(deg[i] == 1) ans++;
								}		
						}
						System.out.println(ans);
				}
		}
}
0