#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ void Solve() { int n; IN(n); string s; IN(s); vector a(n); for (int i : Rep(0, n)) { if (s[i] == '+') { a[i] = i + 1; } else if (s[i] == '-') { a[i] = i - n; } } int ans = Sz(kactl::lis(a)); OUT(ans); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Solve(); } #elif __INCLUDE_LEVEL__ == 1 #include template concept MyRange = std::ranges::range && !std::convertible_to; template concept MyTuple = std::__is_tuple_like::value && !MyRange; namespace std { istream& operator>>(istream& is, MyRange auto&& r) { for (auto&& e : r) is >> e; return is; } istream& operator>>(istream& is, MyTuple auto&& t) { apply([&](auto&... xs) { (is >> ... >> xs); }, t); return is; } ostream& operator<<(ostream& os, MyRange auto&& r) { auto sep = ""; for (auto&& e : r) os << exchange(sep, " ") << e; return os; } ostream& operator<<(ostream& os, MyTuple auto&& t) { auto sep = ""; apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t); return os; } } // namespace std using namespace std; // https://github.com/kth-competitive-programming/kactl namespace kactl { #define rep(i, a, b) for (int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; template vi lis(const vector& S) { if (S.empty()) return {}; vi prev(sz(S)); typedef pair p; vector

res; rep(i, 0, sz(S)) { auto it = lower_bound(all(res), p{S[i], 0}); if (it == res.end()) res.emplace_back(), it = res.end() - 1; *it = {S[i], i}; prev[i] = it == res.begin() ? 0 : (it - 1)->second; } int L = sz(res), cur = res.back().second; vi ans(L); while (L--) ans[L] = cur, cur = prev[cur]; return ans; } #undef sz #undef all #undef rep } // namespace kactl #define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__) #define Sz(r) int(size(r)) #define IN(...) (cin >> forward_as_tuple(__VA_ARGS__)) #define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n') #endif // __INCLUDE_LEVEL__ == 1