結果
問題 | No.672 最長AB列 |
ユーザー |
![]() |
提出日時 | 2018-04-14 14:18:27 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 287 ms / 2,000 ms |
コード長 | 316 bytes |
コンパイル時間 | 95 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 58,800 KB |
最終ジャッジ日時 | 2024-06-27 20:08:00 |
合計ジャッジ時間 | 3,054 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
s = input() a = [0]*len(s) a[0] = 1 if s[0] == "A" else -1 table = {0: [0, 0], a[0]: [1, 0]} for i in range(1, len(s)): a[i] = a[i-1] + (-1, 1)[s[i]=="A"] if a[i] not in table: table[a[i]] = [i+1, 0] else: table[a[i]][1] = i+1 result = [b-a for a, b in table.values()] print(max(result))