結果

問題 No.672 最長AB列
ユーザー takahiro-serikawatakahiro-serikawa
提出日時 2019-05-12 07:34:20
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 275 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 28,056 KB
実行使用メモリ 6,312 KB
最終ジャッジ日時 2023-09-14 18:26:17
合計ジャッジ時間 5,065 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main()
{
	char S[200000+1];
	scanf("%s", S);

	int l = 0;
	for (int j = 0; S[j]; j++)
		for (int i = j, a = 0; S[i]; i++) {
			if (S[i] == 'A')
				a++;
			else
				a--;
			if (a == 0 && l < i-j+1)
				l = i-j+1;
		}

	printf("%d\n", l);
	return 0;
}
0