코드포스
[코드포스 Practice7] A. A pile of stones
불타는강정
2019. 12. 26. 15:26
#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으로 바꿔준다.