結果
問題 |
No.672 最長AB列
|
ユーザー |
![]() |
提出日時 | 2018-05-09 14:29:12 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 487 bytes |
コンパイル時間 | 85 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 19,800 KB |
最終ジャッジ日時 | 2024-06-28 02:41:26 |
合計ジャッジ時間 | 3,947 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 6 TLE * 1 -- * 9 |
ソースコード
S = input() dictN = {} listA = [0] dictMIN = {0:0} mx = 0 count = 0 for a,b in enumerate(S): if b == "A": count += 1 else: count -= 1 if count in dictMIN: dictN[count] = a + 1 else: dictMIN[count] = a + 1 if not count in listA: listA.append(count) for a in listA: try: if dictN[a] - dictMIN[a] > mx: mx = dictN[a] - dictMIN[a] except KeyError: pass print(str(mx) + "\n")