結果

問題 No.3144 Parentheses Modification and Rotation (01 Ver.)
ユーザー pitP
提出日時 2025-05-16 22:31:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 237 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2025-06-28 15:06:17
合計ジャッジ時間 3,562 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if N % 2:
    print(-1)
else:
    A = [(1 if S[i]== '(' else -1) for i in range(N)]
    s = sum(A)
    if s == 0:
        print(0)
    else:
        print(abs(s) // 2)
0