結果

問題 No.3144 Parentheses Modification and Rotation (01 Ver.)
コンテスト
ユーザー pitP
提出日時 2025-05-16 22:31:37
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 101 ms / 2,000 ms
+ 908µs
コード長 237 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 303 ms
コンパイル使用メモリ 21,536 KB
実行使用メモリ 17,400 KB
最終ジャッジ日時 2026-07-16 07:30:21
合計ジャッジ時間 6,363 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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