結果
| 問題 | No.684 Prefix Parenthesis |
| コンテスト | |
| ユーザー |
prd_xxx
|
| 提出日時 | 2018-05-12 00:07:01 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 380 bytes |
| 記録 | |
| コンパイル時間 | 872 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 15,488 KB |
| 最終ジャッジ日時 | 2026-03-16 22:02:31 |
| 合計ジャッジ時間 | 5,003 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 WA * 5 |
ソースコード
N = int(input())
S = input()
pair_sum = op_sum = cl_sum = 0
pair = op = cl = 0
for c in S:
if c == '(':
op += 1
else:
if op > 0:
op -= 1
pair += 1
else:
cl += 1
op_sum += op
cl_sum += cl
pair_sum += pair
for c in S:
if c == '(': break
cl_sum -= 1
print(pair_sum*2 + min(op_sum, cl_sum)*2)
prd_xxx