結果

問題 No.684 Prefix Parenthesis
ユーザー kerotonokerotono
提出日時 2018-05-12 00:13:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 253 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 10,676 KB
実行使用メモリ 8,384 KB
最終ジャッジ日時 2023-09-10 18:02:44
合計ジャッジ時間 2,419 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,816 KB
testcase_01 WA -
testcase_02 AC 15 ms
7,860 KB
testcase_03 WA -
testcase_04 AC 37 ms
8,164 KB
testcase_05 WA -
testcase_06 AC 24 ms
7,828 KB
testcase_07 AC 38 ms
8,188 KB
testcase_08 AC 18 ms
7,720 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 19 ms
7,848 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 26 ms
7,836 KB
testcase_16 AC 45 ms
8,240 KB
testcase_17 AC 32 ms
8,112 KB
testcase_18 AC 15 ms
7,720 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 49 ms
8,272 KB
testcase_22 AC 46 ms
8,364 KB
testcase_23 WA -
testcase_24 AC 48 ms
8,196 KB
testcase_25 AC 51 ms
8,384 KB
testcase_26 AC 15 ms
7,808 KB
testcase_27 WA -
testcase_28 AC 15 ms
7,804 KB
testcase_29 WA -
testcase_30 AC 50 ms
8,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!python
# -*- coding: utf-8 -*-

N = int(input())
S = input()

R = 0
L = 0
for i, c in enumerate(S):
    if c == '(':
        L += len(S) - i
    else:
        R += len(S) - i
if S[0] == ')':
    print(min(R, L) * 2 - 2)
else:
    print(min(R, L) * 2)
0