結果

問題 No.2924 <===Super Spaceship String===>
コンテスト
ユーザー i_taku
提出日時 2025-10-17 11:19:34
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 141 ms / 2,000 ms
+ 137µs
コード長 366 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 236 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 130,252 KB
最終ジャッジ日時 2026-07-15 18:56:43
合計ジャッジ時間 2,440 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

S = input()
stack = []
for c in S:
    if len(stack) >= 2 and stack[-2][0] == '<' and stack[-1][0] == '=' and c == '>':
        stack.pop()
        _, cnt = stack.pop()
    else:
        if stack and stack[-1][0] == c == '=':
            stack[-1] = (c, stack[-1][1] + 1)
        else:
            stack.append((c, 1)) 

ans = sum(cnt for _, cnt in stack)
print(ans)
0