結果
| 問題 | No.684 Prefix Parenthesis |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:59:57 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 298 bytes |
| 記録 | |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 95,468 KB |
| 実行使用メモリ | 83,220 KB |
| 最終ジャッジ日時 | 2026-07-08 05:46:53 |
| 合計ジャッジ時間 | 4,291 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 WA * 5 |
ソースコード
n = int(input())
s = input().strip()
x = 0
while x < len(s) and s[x] == ')':
x += 1
L_total = 0
R_total = 0
for j in range(n):
if s[j] == '(':
L_total += (n - j)
else:
R_total += (n - j)
effective_r = max(0, R_total - x)
ans = 2 * min(L_total, effective_r)
print(ans)
lam6er