結果
問題 |
No.22 括弧の対応
|
ユーザー |
|
提出日時 | 2016-06-07 00:44:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 376 bytes |
コンパイル時間 | 754 ms |
コンパイル使用メモリ | 64,392 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-08 16:57:22 |
合計ジャッジ時間 | 1,666 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 18 |
ソースコード
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; string line; cin >> line; int target = 0, current = 0; for (int i = 1; i < n; i++) { if (line[i] == '(') current++; else current--; if (i == k - 1) target = current; } for (int i = 0; i < n; i++) { if (i != k && current == target) { cout << i + 1 << endl; return 0; } } }