結果

問題 No.672 最長AB列
ユーザー hang_hang_clnhang_hang_cln
提出日時 2018-05-07 21:30:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 428 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 10,528 KB
実行使用メモリ 12,780 KB
最終ジャッジ日時 2023-09-10 10:57:14
合計ジャッジ時間 3,998 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,880 KB
testcase_01 AC 16 ms
7,776 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 16 ms
7,796 KB
testcase_05 AC 15 ms
7,852 KB
testcase_06 AC 15 ms
7,840 KB
testcase_07 AC 15 ms
7,904 KB
testcase_08 AC 16 ms
7,812 KB
testcase_09 RE -
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
if len(S) < 2 or S.count('A') == 0 or S.count('B') == 0:
    print('0')
else:
    maxCutLength = 0
    for cutLength in range(2,len(S)+1):
        for startIndex in range(0,len(S)-cutLength+1):
            if S[startIndex:startIndex+cutLength].count('A') == S[startIndex:startIndex+cutLength].count('B'):
                if cutLength > maxCutLength:
                    maxCutLength = cutLength

print (maxCutLength)
0