結果

問題 No.145 yukiover
ユーザー htensai
提出日時 2020-05-14 16:33:00
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,372 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 77,320 KB
実行使用メモリ 42,792 KB
最終ジャッジ日時 2024-09-15 10:52:39
合計ジャッジ時間 7,691 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 11 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		int total = 0;
		int[] counts = new int[6]; // y - u - k -
		for (char c : arr) {
		    if (c > 'y') {
		        total++;
		    } else if (c == 'y') {
		        counts[0]++;
		    } else if (c > 'u') {
		        counts[1]++;
		    } else if (c == 'u') {
		        counts[2]++;
		    } else if (c > 'k') {
		        counts[3]++;
		    } else if (c == 'k') {
		        counts[4]++;
		    } else if (c > 'i') {
		        counts[5]++;
		    }
		}
		if (counts[4] > counts[5]) {
		    int sum = counts[4] + counts[5];
		    counts[4] = sum / 2;
		    counts[5] = sum / 2;
		}
	    int cnt = Math.min(Math.min(counts[0], counts[2]), Math.min(counts[4], counts[5]));
	    total += cnt;
	    counts[0] -= cnt;
	    counts[2] -= cnt;
		if (counts[2] > counts[3]) {
		    int sum = counts[2] + counts[3];
		    counts[2] = sum / 2;
		    counts[3] = sum / 2;
		}
	    cnt = Math.min(counts[0], Math.min(counts[2], counts[3]));
	    total += cnt;
	    counts[0] -= cnt;
		if (counts[0] > counts[1]) {
		    int sum = counts[0] + counts[1];
		    counts[0] = sum / 2;
		    counts[1] = sum / 2;
		}
	    cnt = Math.min(counts[0], counts[1]);
	    total += cnt;
		System.out.println(total);
	}
}
0