結果
| 問題 | 
                            No.684 Prefix Parenthesis
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 19:14:17 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 191 bytes | 
| コンパイル時間 | 206 ms | 
| コンパイル使用メモリ | 82,432 KB | 
| 実行使用メモリ | 67,840 KB | 
| 最終ジャッジ日時 | 2025-06-12 19:14:39 | 
| 合計ジャッジ時間 | 3,155 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 14 WA * 17 | 
ソースコード
n = int(input())
s = input().strip()
total = 0
left = 0
right = 0
for c in s:
    if c == '(':
        left += 1
    else:
        right += 1
    total += min(left, right)
print(total * 2)
            
            
            
        
            
gew1fw