結果

問題 No.22 括弧の対応
ユーザー hayakawa4739hayakawa4739
提出日時 2016-07-04 19:04:08
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 481 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 20,352 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 21:54:58
合計ジャッジ時間 975 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 0 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 1 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 0 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 == count){
			i = -1;
		}else {
			if(kakko[i] == '('){
				kazu++;
			}else{
				kazu--;
			}
			if(kazu == 0){
				printf("%d",i+1);
				break;
			}
		}
	}



	return 0;
}
0