結果
| 問題 | No.1961 Clear Brackets |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-27 22:16:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 670 bytes |
| コンパイル時間 | 171 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 75,904 KB |
| 最終ジャッジ日時 | 2024-09-20 16:01:46 |
| 合計ジャッジ時間 | 3,831 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 30 |
ソースコード
n = int(input())
S = input().strip()
ans = 0
mi = 0
tot = 0
flg = False
flg2 = False
for s in S:
if s == "(":
tot += 1
flg = True
elif s == ")":
tot -= 1
flg2 = True
if tot < mi:
mi = tot
if flg:
ans += 1
flg = False
flg2 = False
else:
if flg:
tot -= 1
flg2 = True
if tot < mi:
mi = tot
if flg:
ans += 1
flg = False
flg2 = False
else:
tot += 1
flg = True
ans += flg2
print(ans)