結果
| 問題 |
No.684 Prefix Parenthesis
|
| コンテスト | |
| ユーザー |
prd_xxx
|
| 提出日時 | 2018-05-12 00:14:21 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 402 bytes |
| コンパイル時間 | 78 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-06-28 09:14:36 |
| 合計ジャッジ時間 | 2,835 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 10 |
ソースコード
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
pena = 0
for c in S:
if c == '(': break
pena += 1
print(pair_sum*2 + max(0, min(op_sum, cl_sum) - pena)*2)
prd_xxx