結果

問題 No.145 yukiover
ユーザー onigiryonigiry
提出日時 2021-08-21 18:53:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,530 bytes
コンパイル時間 3,344 ms
コンパイル使用メモリ 79,384 KB
実行使用メモリ 44,608 KB
最終ジャッジ日時 2024-04-23 09:35:52
合計ジャッジ時間 9,035 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,188 KB
testcase_01 WA -
testcase_02 AC 144 ms
41,452 KB
testcase_03 WA -
testcase_04 AC 134 ms
41,728 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 136 ms
41,348 KB
testcase_10 WA -
testcase_11 AC 240 ms
43,728 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 211 ms
43,648 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

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 (yCount-- > 0) {
				luck++;
				continue;
			}

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

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

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

		}

		System.out.println(luck);

	}
}
0