結果

問題 No.3144 Parentheses Modification and Rotation (01 Ver.)
ユーザー titia
提出日時 2025-05-16 22:03:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 252 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-06-26 23:11:26
合計ジャッジ時間 3,030 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
S=input().strip()
R,M=map(int,input().split())

if N%2!=0:
    print(-1)
    exit()


x=0
y=0

for s in S:
    if s=="(":
        x+=1
    else:
        y+=1

ANS=(max(x,y)-min(x,y))//2

print(ANS)
0