結果

問題 No.145 yukiover
ユーザー onigiryonigiry
提出日時 2021-08-21 18:45:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,448 bytes
コンパイル時間 3,115 ms
コンパイル使用メモリ 79,184 KB
実行使用メモリ 58,580 KB
最終ジャッジ日時 2024-04-23 09:28:08
合計ジャッジ時間 8,009 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
54,524 KB
testcase_01 AC 115 ms
53,612 KB
testcase_02 AC 109 ms
52,548 KB
testcase_03 AC 106 ms
52,372 KB
testcase_04 AC 115 ms
54,044 KB
testcase_05 WA -
testcase_06 AC 111 ms
53,636 KB
testcase_07 AC 113 ms
53,976 KB
testcase_08 WA -
testcase_09 AC 116 ms
53,792 KB
testcase_10 WA -
testcase_11 AC 196 ms
56,284 KB
testcase_12 WA -
testcase_13 AC 195 ms
56,200 KB
testcase_14 AC 204 ms
56,628 KB
testcase_15 WA -
testcase_16 AC 177 ms
56,520 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 200 ms
56,652 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) {
					kCountup--;
					luck++;
					continue;
				}

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

		}

		System.out.println(luck);

	}
}
0