結果

問題 No.2924 <===Super Spaceship String===>
ユーザー けんたろう
提出日時 2024-10-12 16:07:37
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 3,762 ms
コンパイル使用メモリ 278,856 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-12 16:07:42
合計ジャッジ時間 4,391 ms
ジャッジサーバーID
(参考情報)
judge / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main(void)
{
	string S; cin >> S;
	stack<int> s;

	int ans = 0;

	bool avail = false;

	rep(i, S.size())
	{
		if (S[i] == '<')
		{
			s.push(i);
			avail = true;
		}
		else if (S[i] == '>')
		{
			if (!avail)
			{
				continue;
			}
			if (!s.empty())
			{
				int j = s.top(); s.pop();
				if (i - j == 1)
				{
					avail = false;
					continue;
				}
				else
				{
					ans = max(ans, i - j + 1);
				}
			}
			else
			{
				avail = false;
			}
		}
	}

	cout << S.size() - ans << endl;
	return 0;
}
0