結果
問題 | No.3142 Balancing with O=>X Flip |
ユーザー |
|
提出日時 | 2025-05-16 21:41:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 358 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 82,520 KB |
実行使用メモリ | 77,924 KB |
最終ジャッジ日時 | 2025-05-16 23:53:33 |
合計ジャッジ時間 | 2,416 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
n = int(input()) s = input() a = [0] b = [0] for i in range(n): if s[i] == "(": a.append(a[-1] + 1) if s[i] == ")": a.append(a[-1] + -1) for i in range(n - 1, -1, -1): if s[i] == ")": b.append(b[-1] + 1) if s[i] == "(": b.append(b[-1] + -1) # print(a, b) if a[-1] == 0 and min(a) == 0 and min(b) == 0: print("Yes") else: print("No")