結果
| 問題 |
No.684 Prefix Parenthesis
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:55:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 419 bytes |
| コンパイル時間 | 206 ms |
| コンパイル使用メモリ | 82,352 KB |
| 実行使用メモリ | 69,548 KB |
| 最終ジャッジ日時 | 2025-06-12 16:55:21 |
| 合計ジャッジ時間 | 2,926 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 19 |
ソースコード
n = int(input())
s = input().strip()
left = 0
right = 0
total_L = 0
total_R = 0
total_d = 0
valid = False
for i in range(n):
c = s[i]
if c == '(':
left += 1
else:
right += 1
d = left - right
if d >= 0:
total_L += left
total_R += right
total_d += d
valid = True
if valid:
min_val = min(total_L, total_R)
print(2 * min_val)
else:
print(0)
gew1fw