結果

問題 No.1961 Clear Brackets
ユーザー 👑 ygussanyygussany
提出日時 2022-05-27 22:47:43
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 432 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 29,488 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 20:34:07
合計ジャッジ時間 1,729 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
4,348 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 3 ms
4,348 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,348 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,348 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 2 ms
4,348 KB
testcase_36 WA -
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,348 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main()
{
	int N;
	char S[200001];
	scanf("%d", &N);
	scanf("%s", S);
	
	int i, k, ans = 0;
	for (i = 0, k = 1; i < N; i++) {
		if (k == 0) {
			if (S[i] == '(') k = 2;
			else if (S[i] == '?') {
				if (S[i+1] == '?' || S[i+1] == ')') k = 2;
			}
		} else {
			if (S[i] == '(') k++;
			else {
				k--;
				if (k == 0) ans++;
			}
		}
	}
	if (k == 1) ans++;
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}
0