結果
問題 | No.672 最長AB列 |
ユーザー | tonnnura172 |
提出日時 | 2020-04-13 18:28:57 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 179 ms / 2,000 ms |
コード長 | 998 bytes |
コンパイル時間 | 89 ms |
コンパイル使用メモリ | 10,868 KB |
実行使用メモリ | 25,452 KB |
最終ジャッジ日時 | 2023-10-01 03:14:55 |
合計ジャッジ時間 | 4,206 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
9,420 KB |
testcase_01 | AC | 26 ms
9,420 KB |
testcase_02 | AC | 27 ms
9,404 KB |
testcase_03 | AC | 26 ms
9,468 KB |
testcase_04 | AC | 28 ms
9,536 KB |
testcase_05 | AC | 27 ms
9,444 KB |
testcase_06 | AC | 28 ms
9,468 KB |
testcase_07 | AC | 28 ms
9,380 KB |
testcase_08 | AC | 28 ms
9,372 KB |
testcase_09 | AC | 121 ms
25,452 KB |
testcase_10 | AC | 151 ms
22,296 KB |
testcase_11 | AC | 155 ms
22,284 KB |
testcase_12 | AC | 166 ms
14,348 KB |
testcase_13 | AC | 179 ms
19,080 KB |
testcase_14 | AC | 168 ms
14,864 KB |
testcase_15 | AC | 173 ms
16,008 KB |
testcase_16 | AC | 176 ms
17,096 KB |
testcase_17 | AC | 161 ms
22,200 KB |
testcase_18 | AC | 173 ms
12,900 KB |
ソースコード
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul, add from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from math import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 S = input() l = [0] tmp = 0 for s in S: if s == "A": tmp += 1 else: tmp -= 1 l.append(tmp) check = [None]*(len(S)+1) ans = 0 for i, x in enumerate(l): if check[x] != None: ans = max(ans, i-check[x]) else: check[x] = i print(ans)