03d

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
393 B
1
Indexable
Never
#include <iostream>
using namespace std;

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	int level, cur = -1; cin >> level;
	string brackets, ans=""; cin >> brackets;

	for (int i = 0; i < brackets.size(); i++) {
		if (brackets[i] == '(') cur++;
		if (cur < level) ans += brackets[i];
		if (brackets[i] == ')') cur--;
	}

	cout << ans;
	return 0;
}