結果

問題 No.3142 Balancing with O=>X Flip
ユーザー N-noa21
提出日時 2025-05-17 00:08:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 275 bytes
コンパイル時間 1,113 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 67,396 KB
最終ジャッジ日時 2025-05-17 00:09:02
合計ジャッジ時間 3,103 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(input())
if S.count("(") == S.count(")"):

    cnt = 0
    for i in S:
        if i == "(":
            cnt += 1
        else:
            cnt -= 1
        if cnt < 0:
            print("No")
            exit()
    print("Yes")
else:
    print("No")
0