結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2023-04-21 12:01:08 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,189 bytes |
コンパイル時間 | 4,602 ms |
コンパイル使用メモリ | 111,156 KB |
実行使用メモリ | 29,444 KB |
最終ジャッジ日時 | 2024-11-06 08:11:42 |
合計ジャッジ時間 | 2,341 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 WA * 13 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; namespace yukicoder { class Program { static void Main(string[] args) { var line1 = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray(); string line2 = Console.ReadLine(); int n = line1[0]; int k = line1[1]; string s = line2; int[] chk = new int[n]; for(int i = 0;i < n;i++) { int kakko = 1; for(int j = i+1;j < n;j++) { if(chk[j] != 0) { break; } if('('.Equals(s[j])) { kakko++; }else { kakko--; } if(kakko == 0) { chk[i] = j + 1; chk[j] = i + 1; } } } Console.WriteLine(chk[k - 1]); } } }