結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
kmtrc130
|
| 提出日時 | 2017-04-03 16:28:35 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 857 bytes |
| 記録 | |
| コンパイル時間 | 1,768 ms |
| コンパイル使用メモリ | 111,128 KB |
| 実行使用メモリ | 26,148 KB |
| 最終ジャッジ日時 | 2026-03-29 19:28:57 |
| 合計ジャッジ時間 | 1,540 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 5 |
コンパイルメッセージ
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--;
}
idx = +1;
}
Console.WriteLine(idx);
}
}
kmtrc130