結果
問題 |
No.2924 <===Super Spaceship String===>
|
ユーザー |
|
提出日時 | 2025-10-17 11:09:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 552 bytes |
コンパイル時間 | 408 ms |
コンパイル使用メモリ | 82,704 KB |
実行使用メモリ | 136,188 KB |
最終ジャッジ日時 | 2025-10-17 11:09:45 |
合計ジャッジ時間 | 2,423 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 WA * 5 |
ソースコード
S = input() rle = [] pc = S[0] cnt = 1 for c in S[1:]: if c == pc: cnt += 1 else: rle.append((pc, cnt)) pc = c cnt = 1 rle.append((pc, cnt)) stack = [] for c, cnt in rle: while c == '>' and cnt > 0 and len(stack) >= 2 and stack[-2][0] == '<' and stack[-1][0] == '=': _, eq_cnt = stack.pop() _, lt_cnt = stack.pop() if lt_cnt > 1: stack.append(('<', lt_cnt - 1)) cnt -= 1 if cnt > 0: stack.append((c, cnt)) ans = sum(cnt for _, cnt in stack) print(ans)