結果

問題 No.588 空白と回文
ユーザー GrenacheGrenache
提出日時 2017-11-03 22:46:14
言語 Java19
(openjdk 21)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 3,270 ms
コンパイル使用メモリ 73,664 KB
実行使用メモリ 56,196 KB
最終ジャッジ日時 2023-08-14 17:06:21
合計ジャッジ時間 7,499 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,424 KB
testcase_01 AC 118 ms
53,904 KB
testcase_02 AC 119 ms
55,560 KB
testcase_03 AC 138 ms
55,872 KB
testcase_04 AC 116 ms
55,708 KB
testcase_05 AC 116 ms
55,976 KB
testcase_06 AC 118 ms
55,616 KB
testcase_07 AC 119 ms
55,676 KB
testcase_08 AC 119 ms
55,840 KB
testcase_09 AC 118 ms
55,528 KB
testcase_10 AC 119 ms
55,832 KB
testcase_11 AC 142 ms
55,648 KB
testcase_12 AC 145 ms
55,604 KB
testcase_13 AC 116 ms
55,664 KB
testcase_14 AC 119 ms
55,376 KB
testcase_15 AC 118 ms
55,720 KB
testcase_16 AC 119 ms
56,196 KB
testcase_17 AC 139 ms
55,648 KB
testcase_18 AC 118 ms
55,648 KB
testcase_19 AC 118 ms
56,096 KB
testcase_20 AC 144 ms
55,848 KB
testcase_21 AC 139 ms
55,604 KB
testcase_22 AC 144 ms
55,364 KB
testcase_23 AC 138 ms
55,540 KB
testcase_24 AC 116 ms
55,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder588 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();
		int n = s.length;

		int max = 0;
		for (int i = 0; i < n; i++) {
			int tmp = 1;
			for (int j = 1; i - j >= 0 && i + j < n; j++) {
				if (s[i - j] == s[i + j]) {
					tmp += 2;
				}
			}

			max = Math.max(max, tmp);
		}

		for (int i = 0; i < n; i++) {
			int tmp = 0;
			for (int j = 0; i - j >= 0 && i + 1 + j < n; j++) {
				if (s[i - j] == s[i + 1 + j]) {
					tmp += 2;
				}
			}

			max = Math.max(max, tmp);
		}

		pr.println(max);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0