Submission #904465
Source Code Expand
#ifdef DEBUG #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define sz(s) ((int) ((s).size())) #define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr) #ifdef _WIN32 #define LLD "%I64d" #else #define LLD "%lld" #endif typedef long long ll; typedef long double ld; const int inf = (int) 1e9 + 100; const ld eps = 1e-11; const ld pi = acos(-1.0L); mt19937 mrand(random_device{} ()); int rnd(int x) { return mrand() % x; } void precalc() { } const int maxn = 5e5 + 100; int n; char s[maxn]; bool read() { if (scanf("%s", s) < 1) { return false; } return true; } void solve() { int cnt = 0; int len = strlen(s); for (int i = 0; s[i]; i++) { if (s[i] == 'S') { cnt++; } else { if (cnt > 0) { len -= 2; cnt--; } } } printf("%d\n", len); } int main() { precalc(); #ifdef DEBUG assert(freopen("text.in", "r", stdin)); assert(freopen("text.out", "w", stdout)); #endif while (true) { if (!read()) { break; } solve(); #ifdef DEBUG eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC); #endif } return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | StanislavErshov |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1274 Byte |
Status | AC |
Exec Time | 4 ms |
Memory | 384 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 | 3 ms | 384 KB |
corner1 | AC | 3 ms | 384 KB |
corner2 | AC | 4 ms | 384 KB |
example0 | AC | 3 ms | 256 KB |
example1 | AC | 3 ms | 256 KB |
example2 | AC | 3 ms | 256 KB |
handmade0 | AC | 3 ms | 256 KB |
handmade1 | AC | 3 ms | 256 KB |
maxrand0 | AC | 4 ms | 384 KB |
sub_corner0 | AC | 3 ms | 256 KB |
sub_corner1 | AC | 3 ms | 256 KB |
sub_corner2 | AC | 3 ms | 256 KB |
sub_rand0 | AC | 3 ms | 256 KB |