結果

問題 No.2924 <===Super Spaceship String===>
コンテスト
ユーザー manuo
提出日時 2024-10-12 15:37:22
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 91 ms / 2,000 ms
+ 669µs
コード長 855 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 75 ms
コンパイル使用メモリ 80,768 KB
実行使用メモリ 110,848 KB
最終ジャッジ日時 2026-09-19 00:05:38
合計ジャッジ時間 2,374 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
from functools import cmp_to_key, cache
from heapq import heappop, heappush
import math, sys
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
sys.setrecursionlimit(10**7)
_int = lambda x: int(x)-1
MOD = 998244353
INF = 1<<62
Yes, No = "Yes", "No"

S = input()
N = len(S)
minus = 0
stack = []
C = defaultdict(int)
for i, c in enumerate(S):
    if c == "<":
        stack.append(i)
    elif c == ">":
        if stack:
            l = stack.pop()
            if C[l] > 0:
                minus += C[l]+2
            else:
                stack.append(l)
                C[l] = -1
    else:
        if stack:
            l = stack[-1]
            if C[l] >= 0:
                C[l] += 1
print(N-minus)
0