Submission #2598224


Source Code Expand

Copy
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int N = Integer.parseInt(sc.next());
    String X = sc.next();
    
    for (int i = 0; i < N; i++) {
      char input = X.charAt(i);
      if (input == 'S') {
        A = Math.max(0, A - 1);
      } else if (input == 'C') {
        B = Math.max(0, B - 1);
      } else if (A >= B) {
        A = Math.max(0, A - 1);
      } else {
        B = Math.max(0, B - 1);
      }
    }
    System.out.println(A);
    System.out.println(B);
  }
}

Submission Info

Submission Time
Task B - 洋菓子店
User asuma
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 694 Byte
Status
Exec Time 159 ms
Memory 23880 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
All 200 / 200 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Case Name Status Exec Time Memory
01.txt 159 ms 21460 KB
02.txt 115 ms 19028 KB
03.txt 130 ms 19540 KB
04.txt 116 ms 21972 KB
05.txt 119 ms 18900 KB
06.txt 147 ms 23880 KB
07.txt 99 ms 20052 KB
08.txt 88 ms 19796 KB
sample-01.txt 88 ms 19156 KB
sample-02.txt 88 ms 21716 KB
sample-03.txt 88 ms 21716 KB
sample-04.txt 90 ms 17620 KB