結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,380 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 < 26; i++)
	{
		while (count['y' - 'a'] > 0 && count['u' - 'a'] > 0 && count['k' - 'a'] > 0 && count['i' - 'a'] > 0 && count[i] > 0){
			count['y' - 'a']--;
			count['u' - 'a']--;
			count['k' - 'a']--;
			count['i' - 'a']--;
			count[i]--;
			ans++;
		}
	}

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


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


	for (int i = 'u' - 'a' + 1; i < 26; i++)
	{
		while (count['y' - 'a'] > 0 && count[i] > 0){
			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