結果

問題 No.22 括弧の対応
ユーザー mbanmban
提出日時 2016-11-04 16:35:02
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 5,000 ms
コード長 734 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 102,100 KB
実行使用メモリ 22,884 KB
最終ジャッジ日時 2023-09-27 13:10:08
合計ジャッジ時間 4,125 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,748 KB
testcase_01 AC 57 ms
20,828 KB
testcase_02 AC 58 ms
22,808 KB
testcase_03 AC 58 ms
20,736 KB
testcase_04 AC 60 ms
20,732 KB
testcase_05 AC 59 ms
20,732 KB
testcase_06 AC 58 ms
20,688 KB
testcase_07 AC 59 ms
18,800 KB
testcase_08 AC 60 ms
20,872 KB
testcase_09 AC 59 ms
20,824 KB
testcase_10 AC 58 ms
20,840 KB
testcase_11 AC 60 ms
22,808 KB
testcase_12 AC 59 ms
22,744 KB
testcase_13 AC 59 ms
20,744 KB
testcase_14 AC 59 ms
22,848 KB
testcase_15 AC 60 ms
22,884 KB
testcase_16 AC 60 ms
22,880 KB
testcase_17 AC 59 ms
20,812 KB
testcase_18 AC 57 ms
20,732 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Magatro
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int K = int.Parse(s[1])-1;
        string SS = Console.ReadLine();
        List<int> L = new List<int>();
        int[] c = new int[N];
        for(int i = 0; i < N; i++)
        {
            if (SS[i] == '(')
            {
                L.Add(i);
            }
            else
            {
                c[L[L.Count-1]] = i;
                c[i] = L[L.Count - 1];
                L.RemoveAt(L.Count - 1);
            }
        }
        Console.WriteLine(c[K]+1);
    }
}
0