結果
問題 | No.672 最長AB列 |
ユーザー | 👑 rin204 |
提出日時 | 2020-08-05 17:22:30 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 362 bytes |
コンパイル時間 | 110 ms |
コンパイル使用メモリ | 11,904 KB |
実行使用メモリ | 22,860 KB |
最終ジャッジ日時 | 2023-10-17 08:05:21 |
合計ジャッジ時間 | 6,073 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
9,980 KB |
testcase_01 | AC | 31 ms
9,980 KB |
testcase_02 | AC | 30 ms
9,980 KB |
testcase_03 | AC | 29 ms
9,980 KB |
testcase_04 | WA | - |
testcase_05 | AC | 29 ms
9,980 KB |
testcase_06 | AC | 29 ms
9,980 KB |
testcase_07 | AC | 28 ms
9,980 KB |
testcase_08 | AC | 29 ms
9,980 KB |
testcase_09 | AC | 473 ms
22,860 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 464 ms
16,540 KB |
testcase_14 | WA | - |
testcase_15 | AC | 450 ms
16,552 KB |
testcase_16 | AC | 474 ms
16,556 KB |
testcase_17 | AC | 473 ms
22,860 KB |
testcase_18 | WA | - |
ソースコード
s = input() l = len(s) bef = [999999 for _ in range(2 * l + 1)] aft = [-1 for _ in range(2 * l + 1)] cnt = 0 bef[l] = 0 for i, ss in enumerate(s): if ss == "A": cnt += 1 else: cnt -= 1 bef[l + cnt] = min(bef[l + cnt], i) aft[l + cnt] = max(aft[l + cnt], i) ans = 0 for b, a in zip(bef, aft): ans = max(a - b, ans) print(ans)