結果

問題 No.22 括弧の対応
ユーザー hayakawa4739hayakawa4739
提出日時 2016-07-04 19:18:25
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 483 bytes
コンパイル時間 346 ms
コンパイル使用メモリ 20,736 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-04-20 21:55:13
合計ジャッジ時間 12,494 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d %d\n", &count, &number);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:14:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%c", &kakko[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void) {

	int count=0, number=0, kazu = 0;
	char kakko[10000];
	int i;
	scanf("%d %d\n", &count, &number);


	//printf("%d %d",count,number);

	for (i = 0; i < count; i++) {
		scanf("%c", &kakko[i]);

	}
	//printf("%c",kakko[i]);


	for (i = number-1; i < 100000; i++) {
		if(i+1 == count){
			i = -1;
		}else {
			if(kakko[i] == '('){
				kazu++;
			}else{
				kazu--;
			}
			if(kazu == 0){
				printf("%d",i+1);
				break;
			}
		}
	}



	return 0;
}
0