Submission #904298
Source Code Expand
import java.io.*; import java.util.*; public class Main { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; void solve() throws IOException { String s = nextToken(); int balance = 0; int ans = s.length(); for (char c : s.toCharArray()) { if (c == 'S') { balance++; } else { if (balance > 0) { ans -= 2; balance--; } } } out.println(ans); } Main() throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } public static void main(String[] args) throws IOException { new Main(); } String nextToken() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (Exception e) { eof = true; return null; } } return st.nextToken(); } String nextString() { try { return br.readLine(); } catch (IOException e) { eof = true; return null; } } int nextInt() throws IOException { return Integer.parseInt(nextToken()); } long nextLong() throws IOException { return Long.parseLong(nextToken()); } double nextDouble() throws IOException { return Double.parseDouble(nextToken()); } }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | mmaxio |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 1313 Byte |
Status | AC |
Exec Time | 136 ms |
Memory | 13344 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 | 122 ms | 12108 KB |
corner1 | AC | 136 ms | 13344 KB |
corner2 | AC | 134 ms | 12412 KB |
example0 | AC | 88 ms | 8144 KB |
example1 | AC | 89 ms | 8276 KB |
example2 | AC | 91 ms | 8144 KB |
handmade0 | AC | 91 ms | 8144 KB |
handmade1 | AC | 91 ms | 8144 KB |
maxrand0 | AC | 120 ms | 12116 KB |
sub_corner0 | AC | 91 ms | 8144 KB |
sub_corner1 | AC | 89 ms | 8144 KB |
sub_corner2 | AC | 89 ms | 8148 KB |
sub_rand0 | AC | 89 ms | 8148 KB |