結果
| 問題 |
No.684 Prefix Parenthesis
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:59:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 298 bytes |
| コンパイル時間 | 243 ms |
| コンパイル使用メモリ | 82,700 KB |
| 実行使用メモリ | 61,260 KB |
| 最終ジャッジ日時 | 2025-03-31 18:00:45 |
| 合計ジャッジ時間 | 2,803 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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