結果

問題 No.22 括弧の対応
ユーザー butsurizukibutsurizuki
提出日時 2016-11-30 15:56:33
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 342 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 23,240 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-18 10:02:56
合計ジャッジ時間 1,945 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,500 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main(void) {
	int n,k,c=1,i;
	char s[16384];
	scanf("%d%d%s",&n,&k,s);
	i = k - 1;
	if(s[i] == '('){
		while(1){
			i++;
			if(s[i] == ')'){c--;}else{c++;}
			if(!c){printf("%d\n",i+1);break;}
		}
	}
	else{
		while(1){
			i++;
			if(s[i] == '('){c--;}else{c++;}
			if(!c){printf("%d\n",i+1);break;}
		}
	}
	return 0;
}
0