結果

問題 No.2240 WAC
ユーザー tentententen
提出日時 2023-08-09 10:20:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,338 bytes
コンパイル時間 2,855 ms
コンパイル使用メモリ 92,076 KB
実行使用メモリ 78,860 KB
最終ジャッジ日時 2024-04-27 01:04:59
合計ジャッジ時間 12,770 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
50,384 KB
testcase_01 AC 46 ms
50,516 KB
testcase_02 AC 48 ms
50,140 KB
testcase_03 AC 47 ms
50,428 KB
testcase_04 AC 48 ms
50,000 KB
testcase_05 AC 49 ms
50,384 KB
testcase_06 AC 49 ms
50,340 KB
testcase_07 AC 49 ms
50,344 KB
testcase_08 AC 48 ms
50,108 KB
testcase_09 AC 48 ms
50,280 KB
testcase_10 AC 343 ms
76,464 KB
testcase_11 AC 352 ms
77,544 KB
testcase_12 WA -
testcase_13 AC 171 ms
63,324 KB
testcase_14 AC 135 ms
55,336 KB
testcase_15 AC 304 ms
66,476 KB
testcase_16 AC 381 ms
76,524 KB
testcase_17 WA -
testcase_18 AC 169 ms
58,264 KB
testcase_19 AC 173 ms
58,848 KB
testcase_20 AC 288 ms
69,636 KB
testcase_21 AC 185 ms
62,392 KB
testcase_22 WA -
testcase_23 AC 195 ms
63,248 KB
testcase_24 WA -
testcase_25 AC 269 ms
66,908 KB
testcase_26 WA -
testcase_27 AC 148 ms
58,016 KB
testcase_28 WA -
testcase_29 AC 96 ms
54,520 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 145 ms
58,720 KB
testcase_33 AC 240 ms
65,808 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 288 ms
67,040 KB
testcase_37 AC 320 ms
77,224 KB
testcase_38 AC 168 ms
62,464 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

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();
        TreeSet<Integer> w = new TreeSet<>();
        TreeSet<Integer> wa = new TreeSet<>();
        TreeSet<Integer> ac = new TreeSet<>();
        TreeSet<Integer> c = new TreeSet<>();
        int count = 0;
        for (int i = 0; i < inputs.length; i++) {
            if (inputs[i] == 'A') {
                if (count < m) {
                    ac.add(i);
                } else {
                    wa.add(i);
                }
                count++;
            } else if (inputs[i] == 'W') {
                w.add(i);
            } else {
                c.add(i);
            }
        }
        if (wa.first() < w.first() || wa.last() < w.last() || ac.first() > c.first() || ac.last() > c.last()) {
            System.out.println("No");
        } else {
            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