結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2019-08-23 10:19:55 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 951 bytes |
コンパイル時間 | 221 ms |
コンパイル使用メモリ | 31,360 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 14:20:18 |
合計ジャッジ時間 | 838 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 5 |
ソースコード
#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); } } } }