結果

問題 No.145 yukiover
ユーザー 37zigen37zigen
提出日時 2018-06-14 19:21:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 228 ms / 5,000 ms
コード長 1,846 bytes
コンパイル時間 2,141 ms
コンパイル使用メモリ 74,832 KB
実行使用メモリ 59,988 KB
最終ジャッジ日時 2023-09-13 04:14:28
合計ジャッジ時間 7,918 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,624 KB
testcase_01 AC 122 ms
56,076 KB
testcase_02 AC 121 ms
55,872 KB
testcase_03 AC 121 ms
55,820 KB
testcase_04 AC 120 ms
56,000 KB
testcase_05 AC 121 ms
55,792 KB
testcase_06 AC 120 ms
56,372 KB
testcase_07 AC 122 ms
55,916 KB
testcase_08 AC 118 ms
56,016 KB
testcase_09 AC 123 ms
55,952 KB
testcase_10 AC 124 ms
58,176 KB
testcase_11 AC 202 ms
57,692 KB
testcase_12 AC 215 ms
58,392 KB
testcase_13 AC 223 ms
58,520 KB
testcase_14 AC 225 ms
59,988 KB
testcase_15 AC 227 ms
57,564 KB
testcase_16 AC 222 ms
57,168 KB
testcase_17 AC 228 ms
58,252 KB
testcase_18 AC 219 ms
58,544 KB
testcase_19 AC 226 ms
58,400 KB
testcase_20 AC 225 ms
58,752 KB
testcase_21 AC 222 ms
57,872 KB
testcase_22 AC 225 ms
58,372 KB
testcase_23 AC 217 ms
58,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	String yuki = "yuki";

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String str = sc.next();
		int abcdefgh = 0, i = 0, j = 0, k = 0, lmnopqrst = 0, u = 0, vwx = 0, y = 0, z = 0;

		for (int t = 0; t < str.length(); ++t) {
			if (str.charAt(t) - 'i' < 0)
				++abcdefgh;
			else if (str.charAt(t) == 'i') {
				++i;
			} else if (str.charAt(t) - 'j' == 0)
				++j;
			else if (str.charAt(t) - 'k' == 0)
				++k;
			else if (str.charAt(t) - 'l' >= 0 && str.charAt(t) - 't' <= 0)
				++lmnopqrst;
			else if (str.charAt(t) - 'u' == 0)
				++u;
			else if (str.charAt(t) - 'v' >= 0 && str.charAt(t) - 'x' <= 0)
				++vwx;
			else if (str.charAt(t) == 'y')
				++y;
			else if (str.charAt(t) == 'z')
				++z;
			else {
				tr(str.charAt(t));
				throw new AssertionError();
			}
		}
		int ans = 0;
		while (y > 0 && u > 0 && k > 0 && i > 0 && abcdefgh > 0) {
			++ans;
			--y;
			--u;
			--k;
			--i;
			--abcdefgh;
		}
		while (y > 0 && u > 0 && k > 0 && i >= 2) {
			++ans;
			--y;
			--u;
			--k;
			i -= 2;
			--abcdefgh;
		}
		while (y > 0 && u > 0 && k > 0 && j > 0) {
			++ans;
			--y;
			--u;
			--k;
			--i;
			--j;
		}
		while (y > 0 && u > 0 && k >= 2) {
			++ans;
			--y;
			--u;
			k -= 2;
		}
		while (y > 0 && u > 0 && lmnopqrst > 0) {
			++ans;
			--y;
			--u;
			--lmnopqrst;
		}
		while (y > 0 && u >= 2) {
			++ans;
			--y;
			u -= 2;
		}
		while (y > 0 && vwx > 0) {
			++ans;
			--y;
			--vwx;
		}
		while (y >= 2) {
			++ans;
			y -= 2;
		}
		while (z > 0) {
			++ans;
			--z;
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0