結果

問題 No.273 回文分解
ユーザー htensaihtensai
提出日時 2019-12-30 10:45:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 973 bytes
コンパイル時間 3,517 ms
コンパイル使用メモリ 83,692 KB
実行使用メモリ 41,612 KB
最終ジャッジ日時 2024-11-07 21:27:47
合計ジャッジ時間 9,724 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
41,396 KB
testcase_01 AC 116 ms
39,904 KB
testcase_02 AC 131 ms
41,176 KB
testcase_03 AC 129 ms
41,048 KB
testcase_04 AC 128 ms
41,328 KB
testcase_05 AC 127 ms
41,224 KB
testcase_06 AC 115 ms
39,860 KB
testcase_07 AC 128 ms
41,260 KB
testcase_08 AC 126 ms
41,268 KB
testcase_09 AC 128 ms
41,264 KB
testcase_10 AC 127 ms
41,328 KB
testcase_11 AC 125 ms
40,808 KB
testcase_12 AC 128 ms
41,256 KB
testcase_13 AC 127 ms
41,044 KB
testcase_14 AC 128 ms
41,276 KB
testcase_15 AC 129 ms
41,504 KB
testcase_16 AC 127 ms
41,072 KB
testcase_17 AC 129 ms
41,612 KB
testcase_18 AC 125 ms
41,300 KB
testcase_19 AC 129 ms
41,216 KB
testcase_20 AC 127 ms
41,336 KB
testcase_21 AC 126 ms
41,224 KB
testcase_22 AC 126 ms
41,336 KB
testcase_23 AC 127 ms
41,008 KB
testcase_24 AC 125 ms
40,820 KB
testcase_25 AC 124 ms
41,364 KB
testcase_26 AC 127 ms
41,196 KB
testcase_27 AC 125 ms
41,124 KB
testcase_28 AC 127 ms
41,184 KB
testcase_29 AC 129 ms
41,168 KB
testcase_30 AC 128 ms
41,236 KB
testcase_31 AC 125 ms
41,172 KB
testcase_32 AC 124 ms
41,180 KB
testcase_33 AC 125 ms
41,212 KB
testcase_34 AC 124 ms
41,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        int length = arr.length;
        int max = 1;
        for (int i = 0; i < arr.length; i++) {
            int left = i;
            int right = i;
            while (left >= 0 && right < arr.length && arr[left] == arr[right]) {
                if (length != right - left + 1) {
                    max = Math.max(max, right - left + 1);
                }
                left--;
                right++;
            }
            left = i;
            right = i + 1;
            while (left >= 0 && right < arr.length && arr[left] == arr[right]) {
                if (length != right - left + 1) {
                    max = Math.max(max, right - left + 1);
                }
                left--;
                right++;
            }
        }
        System.out.println(max);
    }
}
0