結果

問題 No.22 括弧の対応
ユーザー 0w1
提出日時 2016-11-20 01:33:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 355 bytes
コンパイル時間 1,541 ms
コンパイル使用メモリ 170,828 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 06:32:36
合計ジャッジ時間 2,311 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main(){
  int N, K; cin >> N >> K;
  string S; cin >> S;
  stack< int > pos;
  for( int i = 0; i < N; ++i ){
    if( S[ i ] == '(' )
      pos.emplace( i );
    else{
      if( i + 1 == K )
        cout << pos.top() + 1 << endl,
        exit( 0 );
      else
        pos.pop();
    }
  }
  return 0;
}
0