結果
| 問題 | No.2924 <===Super Spaceship String===> | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-10-14 13:44:59 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 11 ms / 2,000 ms | 
| コード長 | 805 bytes | 
| コンパイル時間 | 1,962 ms | 
| コンパイル使用メモリ | 198,092 KB | 
| 最終ジャッジ日時 | 2025-02-24 19:27:56 | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 12 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include<atcoder/modint>
using namespace atcoder;
using mint = modint998244353;
void solve() {
    string S;
    cin >> S;
    stack<int> P;
    for (auto s : S) {
        if (s == '<')P.push(0);
        else if (s == '>') {
            if (!P.empty() && P.top() > 0) {
                P.pop();
            }
            else P.push(-1e9);
        }
        else {
            if (!P.empty() && P.top() >= 0)P.top()++;
            else P.push(-1e9);
        }
    }
    int an = P.size();
    while (!P.empty()) {
        if (P.top() >= 0)an += P.top();
        P.pop();
    }
    cout << an << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // ll T;
    // cin>>T;
    // while(T--)
    solve();
}
            
            
            
        