結果

問題 No.672 最長AB列
ユーザー ほっしいーほっしいー
提出日時 2018-04-14 22:29:40
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 639 bytes
コンパイル時間 3,406 ms
コンパイル使用メモリ 72,308 KB
実行使用メモリ 74,892 KB
最終ジャッジ日時 2023-09-10 04:26:37
合計ジャッジ時間 8,667 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 122 ms
55,880 KB
testcase_02 AC 121 ms
55,840 KB
testcase_03 AC 119 ms
55,784 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 392 ms
68,472 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class 最長AB列 {
	public static int getAns(String str) {
		String a="A" ;
		String[] ar = str.split("");
		int k,l;
		int m=0;
		int ans=0;
	outside:for(k=2;k<=ar.length/2;k=k*2) {
				int x=0;
				int y=0;
				for(l=0;l<=ar.length-k;l++) {
					for(int i=0;i<k;i++) {
						if(ar[i+l].equals(a))
							x++;
						else
							y++;
					}
					if(x==y) {
						m=k;
						break;
					}else if(l==ar.length-k)
						break outside;
			}
		}
		return ans=m;
	}

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str = sc.next();
		System.out.print(getAns(str));
	}

}
0