#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
using namespace std;
using i64 = long long;
int main() {
int n;
scanf("%d", &n);
//printf("%d", n);
string s;
cin >> s;
int count = 0;
for(int i = 0; i < s.size(); i++){
if(s[i] == '-')
count--;
else
count++;
count = max(count, 0);
}
printf("%d", count);
return 0;
}
쉬워서 이제 쓴다.
-이면 --하고 +이면 ++ 하는데 음수가 되면 안되니깐 음수이면 0으로 바꿔준다.
'코드포스' 카테고리의 다른 글
코드포스 풀기 전 준비사항 (0) | 2019.12.28 |
---|---|
[코드포스 Practice7] B. Fake NP (0) | 2019.12.26 |
[코드포스 Practice7] E. Bear and Forgotten Tree 3 (0) | 2019.12.26 |
[코드포스 Practice7] D. Array Splitting (0) | 2019.12.23 |
[코드포스 Practice7] C. Chewbaсca and Number (0) | 2019.12.23 |