結果

問題 No.672 最長AB列
ユーザー pika4632pika4632
提出日時 2018-05-09 11:18:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 25,872 KB
最終ジャッジ日時 2023-09-10 11:16:18
合計ジャッジ時間 4,400 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

S = input()
listS = list(S)
listN = []
listA = []
listMAX = []
count = 0
mx = 0
mn = 0
for a in listS:
    if a == "A":
        count += 1
        listN.append(count)
    if a == "B":
        count -= 1
        listN.append(count)
        
for b in listN:
    if listA.count(b) ==0:
        listA.append(b)
        
for c in listA:
    flag = 0
    for d,e in enumerate(listN):
        if str(e) == str(c) and flag ==0:
            min = int(d)
            flag = 1
        elif str(e) == str(c) and flag ==1:
            mx = int(d)
    listMAX.append(mx - mn)
  
print(max(listMAX))
        
        

    
0