結果

問題 No.717 ファッションへのこだわり
ユーザー YamaKasaYamaKasa
提出日時 2018-07-27 22:30:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 3,399 ms
コンパイル使用メモリ 71,936 KB
実行使用メモリ 56,672 KB
最終ジャッジ日時 2023-09-18 09:54:33
合計ジャッジ時間 6,266 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,236 KB
testcase_01 AC 122 ms
55,560 KB
testcase_02 AC 120 ms
55,860 KB
testcase_03 AC 122 ms
55,708 KB
testcase_04 AC 122 ms
56,212 KB
testcase_05 AC 124 ms
56,052 KB
testcase_06 AC 128 ms
55,856 KB
testcase_07 AC 162 ms
56,672 KB
testcase_08 AC 156 ms
56,296 KB
testcase_09 AC 156 ms
56,200 KB
testcase_10 AC 139 ms
56,248 KB
testcase_11 AC 161 ms
56,396 KB
testcase_12 AC 159 ms
56,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		String S = scan.next();
		String T = scan.next();
		scan.close();
		int a1 = 0;
		int b1 = 0;
		int a2 = 0;
		int b2 = 0;
		for(int i = 0; i < N; i++) {
			char c = S.charAt(i);
			if(c == 'A') {
				a1 ++;
			}else {
				b1 ++;
			}
		}
		for(int i = 0; i < M; i++) {
			char c = T.charAt(i);
			if(c == 'A') {
				a2 ++;
			}else {
				b2 ++;
			}
		}
		int ans = Math.min(a1, a2) + Math.min(b1, b2);
		System.out.println(ans);
	}
}
0