結果
問題 | No.684 Prefix Parenthesis |
ユーザー |
![]() |
提出日時 | 2025-06-12 21:37:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 419 bytes |
コンパイル時間 | 1,261 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 68,528 KB |
最終ジャッジ日時 | 2025-06-12 21:40:15 |
合計ジャッジ時間 | 2,697 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)