結果

問題 No.2240 WAC
ユーザー tentententen
提出日時 2023-03-14 08:49:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 2,225 bytes
コンパイル時間 2,530 ms
コンパイル使用メモリ 87,400 KB
実行使用メモリ 57,548 KB
最終ジャッジ日時 2023-10-18 11:30:04
合計ジャッジ時間 8,287 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
53,432 KB
testcase_01 AC 54 ms
53,428 KB
testcase_02 AC 55 ms
53,432 KB
testcase_03 AC 56 ms
53,436 KB
testcase_04 AC 56 ms
53,428 KB
testcase_05 AC 55 ms
53,436 KB
testcase_06 AC 56 ms
53,436 KB
testcase_07 AC 55 ms
53,432 KB
testcase_08 AC 56 ms
53,424 KB
testcase_09 AC 55 ms
53,436 KB
testcase_10 AC 134 ms
57,384 KB
testcase_11 AC 134 ms
57,548 KB
testcase_12 AC 123 ms
57,268 KB
testcase_13 AC 95 ms
55,004 KB
testcase_14 AC 86 ms
54,108 KB
testcase_15 AC 108 ms
57,344 KB
testcase_16 AC 129 ms
57,396 KB
testcase_17 AC 116 ms
55,252 KB
testcase_18 AC 90 ms
55,360 KB
testcase_19 AC 100 ms
55,224 KB
testcase_20 AC 116 ms
57,072 KB
testcase_21 AC 114 ms
55,392 KB
testcase_22 AC 108 ms
55,260 KB
testcase_23 AC 100 ms
55,340 KB
testcase_24 AC 116 ms
55,580 KB
testcase_25 AC 124 ms
55,528 KB
testcase_26 AC 94 ms
55,496 KB
testcase_27 AC 82 ms
54,216 KB
testcase_28 AC 88 ms
54,484 KB
testcase_29 AC 69 ms
53,648 KB
testcase_30 AC 107 ms
55,344 KB
testcase_31 AC 133 ms
57,396 KB
testcase_32 AC 82 ms
54,480 KB
testcase_33 AC 115 ms
55,272 KB
testcase_34 AC 119 ms
55,492 KB
testcase_35 AC 67 ms
53,596 KB
testcase_36 AC 118 ms
57,548 KB
testcase_37 AC 117 ms
57,236 KB
testcase_38 AC 101 ms
55,364 KB
testcase_39 AC 122 ms
57,252 KB
testcase_40 AC 114 ms
55,428 KB
testcase_41 AC 104 ms
55,480 KB
testcase_42 AC 111 ms
55,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[] inputs = sc.next().toCharArray();
        int wa = 0;
        int ac = 0;
        for (int i = 0; i < inputs.length; i++) {
            if (inputs[i] == 'W') {
                wa++;
            } else if (inputs[i] == 'C') {
                ac--;
                if (ac < 0) {
                    System.out.println("No");
                    return;
                }
            } else {
                if (m > 0) {
                    ac++;
                    m--;
                } else {
                    wa--;
                    if (wa < 0) {
                        System.out.println("No");
                        return;
                    }
                }
            }
        }
        System.out.println("Yes");
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0