結果

問題 No.672 最長AB列
ユーザー dong_fengdong_feng
提出日時 2018-04-19 23:18:40
言語 PHP
(8.3.4)
結果
TLE  
実行時間 -
コード長 772 bytes
コンパイル時間 1,100 ms
コンパイル使用メモリ 18,564 KB
実行使用メモリ 23,420 KB
最終ジャッジ日時 2023-09-10 04:43:51
合計ジャッジ時間 4,029 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
23,392 KB
testcase_01 AC 15 ms
19,044 KB
testcase_02 AC 16 ms
18,852 KB
testcase_03 AC 15 ms
18,844 KB
testcase_04 AC 16 ms
18,796 KB
testcase_05 AC 16 ms
18,748 KB
testcase_06 AC 16 ms
18,816 KB
testcase_07 AC 15 ms
18,904 KB
testcase_08 AC 15 ms
18,964 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

//取得
$charList = array_diff(str_split(fgets(STDIN), 1),array(PHP_EOL, "\n", "\r"));
$listCount = count($charList);

//処理
for($i=$listCount; $i>0; $i--){//文字列を切る長さのループ
	if($i%2==0){	//奇数文字の文字列はやる意味がない
		for($j=0; $j<($listCount-$i+1); $j++){	//文字列のスタート位置を決めるループ
			$count = 0; //Aの個数をカウントしてくれる
			for($k=$j; $k<$j+$i; $k++){	//切り出した文字列を回すループ
				if($charList[$k]=='A') {
					$count ++;
				}
//				echo $charList[$k];
			}
//			echo PHP_EOL;
			if($count == $i/2) {	//Aの個数がちょうど半分なら出力して終わり
//				echo $j.PHP_EOL;
				echo $i.PHP_EOL;
				exit;
			}
		}
	}
}

echo "0".PHP_EOL;
0