結果

問題 No.145 yukiover
ユーザー onigiryonigiry
提出日時 2021-08-21 19:01:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,619 bytes
コンパイル時間 2,755 ms
コンパイル使用メモリ 79,248 KB
実行使用メモリ 44,432 KB
最終ジャッジ日時 2024-04-23 09:42:33
合計ジャッジ時間 7,934 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
41,212 KB
testcase_01 WA -
testcase_02 AC 153 ms
41,376 KB
testcase_03 AC 112 ms
40,740 KB
testcase_04 AC 106 ms
39,712 KB
testcase_05 WA -
testcase_06 AC 115 ms
40,636 KB
testcase_07 AC 116 ms
41,064 KB
testcase_08 AC 104 ms
40,300 KB
testcase_09 AC 114 ms
41,140 KB
testcase_10 WA -
testcase_11 AC 220 ms
43,884 KB
testcase_12 WA -
testcase_13 AC 213 ms
43,180 KB
testcase_14 AC 195 ms
43,220 KB
testcase_15 AC 207 ms
44,432 KB
testcase_16 AC 202 ms
43,448 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 198 ms
43,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		List<Character> sList = new ArrayList<>();
		List<Character> yukiList = new ArrayList<>();

		yukiList.add('y');
		yukiList.add('u');
		yukiList.add('k');
		yukiList.add('i');

		int yCountup = 0;
		int yCount = 0;
		int uCountup = 0;
		int uCount = 0;
		int kCountup = 0;
		int kCount = 0;
		int iCount = 0;

		for (int i = 0; i < n; i++) {
			sList.add(s.charAt(i));
			if (sList.get(i) > 'y') {
				yCountup++;
			} else if(sList.get(i) == 'y') {
				yCount++;
			} else if (sList.get(i) > 'u') {
				uCountup++;
			} else if(sList.get(i) == 'u') {
				uCount++;
			} else if (sList.get(i) > 'k') {
				kCountup++;
			} else if(sList.get(i) == 'k') {
				kCount++;
			} else if (sList.get(i) > 'i') {
				iCount++;
			}
		}

		int luck = 0;

		luck += yCountup;

		for (int i = 1; i <= yCount; i++) {
			if (uCountup-- > 0 ) {
				luck++;
				continue;
			}

			if (uCount > 0) {
				if (kCountup > 0) {
					uCount--;
					kCountup--;
					luck++;
					continue;
				}

				if (kCount > 0) {
					if (iCount > 0) {
						uCount--;
						kCount--;
						iCount--;
						luck++;
						continue;
					}
					if (kCount > 0) {
						uCount--;
						kCount--;
						kCount--;
						luck++;
						continue;
					}
				}
				if (uCount > 0) {
					uCount--;
					uCount--;
					luck++;
					continue;
				}
			}
			if (yCount-- > 0) {
				luck++;
			}
		}

		System.out.println(luck);

	}
}
0