結果
問題 | No.588 空白と回文 |
ユーザー | Grenache |
提出日時 | 2017-11-03 22:46:14 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 139 ms / 2,000 ms |
コード長 | 962 bytes |
コンパイル時間 | 3,250 ms |
コンパイル使用メモリ | 77,632 KB |
実行使用メモリ | 41,708 KB |
最終ジャッジ日時 | 2024-11-22 16:07:29 |
合計ジャッジ時間 | 7,102 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
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);}}}