結果

問題 No.2240 WAC
ユーザー tenten
提出日時 2023-08-09 10:20:32
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 2,338 bytes
コンパイル時間 2,720 ms
コンパイル使用メモリ 85,496 KB
実行使用メモリ 78,716 KB
最終ジャッジ日時 2024-11-14 17:29:42
合計ジャッジ時間 14,578 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29 WA * 14
権限があれば一括ダウンロードができます

ソースコード

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