結果

問題 No.3141 Balancing with X=>O Flip
ユーザー elphe
提出日時 2025-05-17 11:16:39
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 79,044 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-17 11:16:41
合計ジャッジ時間 2,039 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>

using namespace std;

static inline constexpr const char* solve(const uint32_t N, const string& S) noexcept
{
	uint32_t count[2] = { 0, 0 };
	for (uint32_t i = 0; i != N; ++i)
		switch (S[i])
		{
		case '(':
			++count[0];
			break;

		case ')':
			++count[1];
			break;
		}

	if (count[0] == count[1])
		return "Yes";
	else
		return "No";
}

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	uint32_t N;
	string S;
	cin >> N;
	S.reserve(N), cin >> S;

	cout << solve(N, S) << '\n';
	return 0;
}
0