Submission #904471


Source Code Expand

#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};

// const int C ;
// const int M = 1000000007;

int main () {
  string X;
  cin >> X;
  int cntS = 0, cntT = 0;
  for (auto x : X) {
    if (x == 'S') {
      cntS++;
    } else if (x == 'T' && cntS > 0) {
      cntS--;
    } else {
      cntT++;
    }
  }
  cout << cntT * 2 << endl;
}

Submission Info

Submission Time
Task A - STring
User kazunetakahashi
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1059 Byte
Status AC
Exec Time 13 ms
Memory 1152 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
AC × 3
AC × 9
AC × 13
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 13 ms 1152 KB
corner1 AC 9 ms 640 KB
corner2 AC 9 ms 640 KB
example0 AC 2 ms 256 KB
example1 AC 2 ms 256 KB
example2 AC 3 ms 256 KB
handmade0 AC 2 ms 256 KB
handmade1 AC 2 ms 256 KB
maxrand0 AC 10 ms 640 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