結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
7,900 KB
testcase_02 AC 15 ms
7,828 KB
testcase_03 AC 15 ms
7,744 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 17 ms
8,300 KB
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:
    for cutLength in range(2,len(S)+1)[::-1]:
        for startIndex in range(0,len(S)-cutLength+1):
            if S[startIndex:startIndex+cutLength].count('A') == S[startIndex:startIndex+cutLength].count('B'):
                print(cutLength)
                break
0