結果

問題 No.402 最も海から遠い場所
ユーザー 37zigen37zigen
提出日時 2016-07-23 12:00:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 890 ms / 3,000 ms
コード長 747 bytes
コンパイル時間 2,853 ms
コンパイル使用メモリ 77,272 KB
実行使用メモリ 176,516 KB
最終ジャッジ日時 2024-04-24 07:35:03
合計ジャッジ時間 9,455 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
41,240 KB
testcase_01 AC 100 ms
40,244 KB
testcase_02 AC 124 ms
41,624 KB
testcase_03 AC 104 ms
40,232 KB
testcase_04 AC 107 ms
40,316 KB
testcase_05 AC 115 ms
41,220 KB
testcase_06 AC 103 ms
40,316 KB
testcase_07 AC 122 ms
41,156 KB
testcase_08 AC 116 ms
41,296 KB
testcase_09 AC 118 ms
41,352 KB
testcase_10 AC 112 ms
40,232 KB
testcase_11 AC 120 ms
40,604 KB
testcase_12 AC 109 ms
40,484 KB
testcase_13 AC 151 ms
42,036 KB
testcase_14 AC 159 ms
42,024 KB
testcase_15 AC 222 ms
48,020 KB
testcase_16 AC 289 ms
48,880 KB
testcase_17 AC 560 ms
97,300 KB
testcase_18 AC 890 ms
176,516 KB
testcase_19 AC 859 ms
176,248 KB
testcase_20 AC 847 ms
176,348 KB
testcase_21 AC 882 ms
176,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solver();
	}

	static void solver() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] table = new char[H][W];
		dis = new int[H][W];

		for (int i = 0; i < H; i++) {
			table[i] = sc.next().toCharArray();
		}

		int[][] dp = new int[H + 2][W + 2];

		int ans = 0;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if (table[i-1][j-1] == '.')
					continue;
				dp[i][j] = Math.min(dp[i - 1][j - 1] + 1, dp[i - 1][j] + 1);
				dp[i][j] = Math.min(dp[i][j], dp[i][j - 1] + 1);

				ans = Math.max(ans, dp[i][j]);
			}
		}
		System.out.println((ans + 1) / 2);

	}

	static int[][] dis;
}
0