結果
| 問題 | 
                            No.684 Prefix Parenthesis
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 14:25:00 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 187 bytes | 
| コンパイル時間 | 139 ms | 
| コンパイル使用メモリ | 81,956 KB | 
| 実行使用メモリ | 63,096 KB | 
| 最終ジャッジ日時 | 2025-06-12 14:25:04 | 
| 合計ジャッジ時間 | 2,664 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 14 WA * 17 | 
ソースコード
n = int(input())
s = input().strip()
total = 0
count = 0
for i in range(n):
    if s[i] == '(':
        count += 1
    l = count
    r = i + 1 - l
    total += 2 * min(l, r)
print(total)
            
            
            
        
            
gew1fw