結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
prd_xxx
|
| 提出日時 | 2018-04-14 00:03:29 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 444 bytes |
| コンパイル時間 | 449 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 20,964 KB |
| 最終ジャッジ日時 | 2024-06-27 19:59:07 |
| 合計ジャッジ時間 | 4,303 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 TLE * 1 -- * 6 |
ソースコード
S = input()
mem = [0]
a = b = 0
for c in S:
if c == 'A':
mem.append(mem[-1] + 1)
a += 1
else:
mem.append(mem[-1] - 1)
b += 1
def judge(n):
for a,b in zip(mem, mem[n*2:]):
if a == b:
return True
for a,b in zip(mem[1:], mem[n*2+1:]):
if a == b:
return True
return False
for n in range(min(a,b),-1,-1):
if judge(n):
print(n*2)
exit()
prd_xxx