結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2017-04-03 16:27:44 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 835 bytes |
コンパイル時間 | 943 ms |
コンパイル使用メモリ | 106,112 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-07-08 03:22:46 |
合計ジャッジ時間 | 2,251 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 6 |
コンパイルメッセージ
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; class Program { static void Main(string[] args) { int[] NK = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); char[] S = Console.ReadLine().ToArray(); int kakko = 0; int idx = 0; if ('('.Equals(S[NK[1] - 1])) { for (idx = NK[1]; idx < S.Length; idx++) { if (kakko < 0) break; if ('('.Equals(S[idx])) kakko++; if (')'.Equals(S[idx])) kakko--; } } else { for (idx = NK[1] - 2; 0 < idx; idx--) { if (kakko < 0) break; if (')'.Equals(S[idx])) kakko++; if ('('.Equals(S[idx])) kakko--; } } Console.WriteLine(idx); } }