結果

問題 No.145 yukiover
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-04 06:43:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,370 bytes
コンパイル時間 1,141 ms
コンパイル使用メモリ 146,672 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 04:03:55
合計ジャッジ時間 2,155 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

int main() {
	vector<int> count(26);
	int N;
	cin >> N;
	string S;
	cin >> S;
	for (int i = 0; i < N; i++)
	{
		count[S[i] - 'a']++;
	}

	int ans = 0;

	for (int i = 0; i <= 'i' - 'a'; i++)
	{
		while (count['y' - 'a'] > 0 && count['u' - 'a'] > 0 && count['k' - 'a'] > 0 && count['i' - 'a'] > 0 && count[i] > 0 && (i != 'i' - 'a' || count[i] > 1)){
			count['y' - 'a']--;
			count['u' - 'a']--;
			count['k' - 'a']--;
			count['i' - 'a']--;
			count[i]--;
			ans++;
		}
	}

	for (int i = 'i' - 'a' + 1; i <= 'k' - 'a'; i++)
	{
		while (count['y' - 'a'] > 0 && count['u' - 'a'] > 0 && count['k' - 'a'] > 0 && count[i] > 0 && (i != 'k' - 'a' || count[i] > 1)){
			count['y' - 'a']--;
			count['u' - 'a']--;
			count['k' - 'a']--;
			count[i]--;
			ans++;
		}
	}


	for (int i = 'k' - 'a' + 1; i <= 'u' - 'a'; i++)
	{
		while (count['y' - 'a'] > 0 && count['u' - 'a'] > 0 && count[i] > 0 && (i != 'u' - 'a' || count[i] > 1)){
			count['y' - 'a']--;
			count['u' - 'a']--;
			count[i]--;
			ans++;
		}
	}


	for (int i = 'u' - 'a' + 1; i <= 'y' - 'a'; i++)
	{
		while (count['y' - 'a'] > 0 && count[i] > 0 && (i != 'y' - 'a' || count[i] > 1)){
			count['y' - 'a']--;
			count[i]--;
			ans++;
		}
	}

	for (int i = 'y' - 'a' + 1; i < 26; i++)
	{
		while (count[i] > 0){
			count[i]--;
			ans++;
		}
	}


	cout << ans << endl;
}
0