結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
|
提出日時 | 2024-12-25 17:03:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 926 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 82,060 KB |
実行使用メモリ | 80,000 KB |
最終ジャッジ日時 | 2024-12-25 17:03:34 |
合計ジャッジ時間 | 1,855 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
import sys, math sys.setrecursionlimit(10**7) from itertools import * from heapq import heapify, heappush, heappop from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right from copy import copy, deepcopy # from sortedcontainers import SortedSet, SortedList, SortedDict INF, LINF, ipt = float('inf'), 1 << 60, sys.stdin.readline iin, mii = lambda: int(ipt()), lambda: map(int, ipt().split()) lmi = lambda: list(map(int, ipt().split())) S = input() N = len(S) st = deque() ans = N for i in range(N): if S[i] == "<": st.append(1) elif S[i] == "=": st.append(0) else: cnt = 0 while st and st[-1] == 0: cnt += 1 st.pop() if cnt == 0: st.append(-1) continue if st and st[-1] == 1: ans -= cnt + 2 st.pop() else: st.append(-1) print(ans)