結果

問題 No.672 最長AB列
ユーザー turner18_jpturner18_jp
提出日時 2018-04-30 11:46:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 234 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,688 KB
実行使用メモリ 9,772 KB
最終ジャッジ日時 2023-09-10 08:22:09
合計ジャッジ時間 2,204 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,788 KB
testcase_01 WA -
testcase_02 AC 16 ms
7,828 KB
testcase_03 AC 16 ms
7,780 KB
testcase_04 AC 15 ms
7,780 KB
testcase_05 AC 16 ms
7,800 KB
testcase_06 AC 15 ms
7,984 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 53 ms
9,744 KB
testcase_10 AC 77 ms
9,616 KB
testcase_11 AC 91 ms
9,660 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 102 ms
9,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = list(input())
a, b = 0, 0
ans = 0
for c in s:
  if c == "A":
    a += 1
  elif c == "B":
    b += 1

  if a > 0 and b > 0:
    if a >= b and b*2 > ans:
      ans = b * 2
    elif b >= a and a * 2 > ans:
      ans = a*2

print(ans)
0