結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2016-11-04 16:35:02 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 5,000 ms |
| コード長 | 734 bytes |
| コンパイル時間 | 944 ms |
| コンパイル使用メモリ | 110,388 KB |
| 実行使用メモリ | 26,216 KB |
| 最終ジャッジ日時 | 2024-07-20 07:17:55 |
| 合計ジャッジ時間 | 2,300 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
}
}
mban