結果

問題 No.717 ファッションへのこだわり
ユーザー YamaKasa
提出日時 2018-07-27 22:30:04
言語 Java
(openjdk 23)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 2,091 ms
コンパイル使用メモリ 74,296 KB
実行使用メモリ 41,948 KB
最終ジャッジ日時 2024-07-05 01:36:49
合計ジャッジ時間 4,509 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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