Submission #1513209
Source Code Expand
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES // M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip> // 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset> // bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;
#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr) // C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数(Greatest Common Divisor)
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数(Least Common Multiple)
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.
// ------------------- include, typedef, define END. -------------------
int main() {
FAST_IO;
// for D_OUT(str, value) ... cout<< str <<" : "<< value <<endl;
bool dbgF = true;
//コードはここから書く.
// respect http://agc005.contest.atcoder.jp/submissions/1402971
string X;
cin >> X;
LL ans = X.length();
LL Sstock = 0;
FOR(i, 0, X.length()) {
if (X[i] == 'S') {
Sstock++;
}
else {
if (Sstock) {
ans -= 2;
Sstock--;
}
}
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
A - STring |
User |
conchan_akita |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
2853 Byte |
Status |
AC |
Exec Time |
3 ms |
Memory |
720 KB |
Judge Result
Set Name |
Sample |
Subtask1 |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
100 / 100 |
Status |
|
|
|
Set Name |
Test Cases |
Sample |
example0, example1, example2 |
Subtask1 |
example0, example1, example2, sub_corner0, sub_corner1, sub_corner2, sub_rand0, handmade0, handmade1 |
All |
corner0, corner1, corner2, example0, example1, example2, handmade0, handmade1, maxrand0, sub_corner0, sub_corner1, sub_corner2, sub_rand0 |
Case Name |
Status |
Exec Time |
Memory |
corner0 |
AC |
2 ms |
720 KB |
corner1 |
AC |
2 ms |
720 KB |
corner2 |
AC |
2 ms |
720 KB |
example0 |
AC |
1 ms |
256 KB |
example1 |
AC |
1 ms |
256 KB |
example2 |
AC |
1 ms |
256 KB |
handmade0 |
AC |
1 ms |
256 KB |
handmade1 |
AC |
1 ms |
256 KB |
maxrand0 |
AC |
3 ms |
720 KB |
sub_corner0 |
AC |
1 ms |
256 KB |
sub_corner1 |
AC |
1 ms |
256 KB |
sub_corner2 |
AC |
1 ms |
256 KB |
sub_rand0 |
AC |
1 ms |
256 KB |