結果

問題 No.672 最長AB列
ユーザー tamatotamato
提出日時 2020-03-04 20:54:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 394 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 82,524 KB
実行使用メモリ 100,948 KB
最終ジャッジ日時 2024-04-22 01:50:53
合計ジャッジ時間 2,118 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 39 ms
51,712 KB
testcase_02 AC 36 ms
52,096 KB
testcase_03 AC 36 ms
51,712 KB
testcase_04 WA -
testcase_05 AC 36 ms
52,096 KB
testcase_06 AC 35 ms
51,840 KB
testcase_07 AC 31 ms
51,840 KB
testcase_08 AC 35 ms
52,096 KB
testcase_09 AC 71 ms
100,948 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 49 ms
68,224 KB
testcase_14 WA -
testcase_15 AC 50 ms
69,632 KB
testcase_16 AC 49 ms
68,992 KB
testcase_17 AC 58 ms
88,704 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    dic = {}
    tmp = 0
    ans = 0
    for i, s in enumerate(S):
        if s == 'A':
            tmp += 1
        else:
            tmp -= 1
        if tmp not in dic:
            dic[tmp] = i
        else:
            ans = max(ans, i - dic[tmp])
    print(ans)


if __name__ == '__main__':
    main()
0