結果
問題 | No.22 括弧の対応 |
ユーザー | funakoshi |
提出日時 | 2019-08-23 10:20:45 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 974 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 31,232 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:44:22 |
合計ジャッジ時間 | 812 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <math.h> int main(void) { char str[20000]=""; int len,specified,kakko=0,point=0; scanf("%d %d",&len,&specified); scanf("%s",str); if(str[specified-1]=='(') { for(int i=specified-1;i<len;i++) { if(str[i]=='(') { kakko++; } else { kakko--; } if(kakko==0) { printf("%d",i+1); break; } } } else { for(int i=specified-1;0<=i;i--) { if(str[i]=='(') { kakko++; } else { kakko--; } if(kakko==0) { printf("%d",i+1); break; } } } }