Submission #9638204 - AtCoder Grand Contest 005 | AtCoder
// ===================================
// author: M_sea
// website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
#define re register
using namespace std;
inline int read()
{
int X = 0, w = 1;
char c = getchar();
while (c < '0' || c > '9')
{
if (c == '-')
w = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
X = X * 10 + c - '0', c = getchar();
return X * w;
}
const int N = 200000 + 10;
char s[N];
int main()
{
scanf("%s", s + 1);
int n = strlen(s + 1), ans = n;
for (re int i = 1, top = 0; i <= n; ++i)
{
if (s[i] == 'S')
++top;
else if (top)
ans -= 2, --top;
}
printf("%d\n", ans);
return 0;
}
Submission
Task A - STring
User name M_sea
Created time 2020/01/20 08:16:05
Language C++14 (GCC 5.4.1)
Status AC
Score 300
Source length 633 Byte
File name
Exec time 3 ms
Memory usage 384 KB
评论
发表评论