結果
| 問題 | No.672 最長AB列 |
| コンテスト | |
| ユーザー |
prd_xxx
|
| 提出日時 | 2018-04-14 00:03:29 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 444 bytes |
| 記録 | |
| コンパイル時間 | 337 ms |
| コンパイル使用メモリ | 20,824 KB |
| 実行使用メモリ | 41,480 KB |
| 最終ジャッジ日時 | 2026-03-15 21:55:50 |
| 合計ジャッジ時間 | 16,806 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 4 |
ソースコード
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