結果

問題 No.717 ファッションへのこだわり
ユーザー amotoma3amotoma3
提出日時 2018-07-30 22:31:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 2,087 bytes
コンパイル時間 2,967 ms
コンパイル使用メモリ 79,848 KB
実行使用メモリ 51,912 KB
最終ジャッジ日時 2023-10-12 19:30:29
合計ジャッジ時間 4,145 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
51,100 KB
testcase_01 AC 57 ms
51,124 KB
testcase_02 AC 59 ms
51,720 KB
testcase_03 AC 57 ms
50,816 KB
testcase_04 AC 58 ms
50,832 KB
testcase_05 AC 58 ms
50,808 KB
testcase_06 AC 61 ms
50,880 KB
testcase_07 AC 65 ms
51,692 KB
testcase_08 AC 69 ms
51,864 KB
testcase_09 AC 68 ms
51,880 KB
testcase_10 AC 63 ms
51,788 KB
testcase_11 AC 65 ms
51,648 KB
testcase_12 AC 65 ms
51,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task717 solver = new Task717();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task717 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            String s = in.nextString();
            String t = in.nextString();

            long cntAInS = s.chars().filter(c -> c == 'A').count();
            long cntBInS = n - cntAInS;
            long cntAInT = t.chars().filter(c -> c == 'A').count();
            long cntBInT = m - cntAInT;

            out.println(Math.min(cntAInS, cntAInT) + Math.min(cntBInS, cntBInT));
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}

0