結果

問題 No.145 yukiover
ユーザー pekempeypekempey
提出日時 2016-12-22 22:03:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,158 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 168,068 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-21 05:45:44
合計ジャッジ時間 3,001 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	vector<int> cnt(256);
	for (int i = 0; i < n; i++) {
		cnt[s[i]]++;
	}

	int ans = 0;

	// yuki
	for (char i = 'a'; i <= 'i'; i++) {
		while (cnt['y'] > 0 && cnt['u'] > 0 && cnt['k'] > 0 && cnt['i'] > 0 && cnt[i] > 0) {
			if (i == 'i' && cnt['i'] <= 1) {
				break;
			}
			cnt['y']--;
			cnt['u']--;
			cnt['k']--;
			cnt['i']--;
			cnt[i]--;
			ans++;
		}
	}

	// yuk
	for (char i = 'i' + 1; i <= 'k'; i++) {
		while (cnt['y'] > 0 && cnt['u'] > 0 && cnt['k'] > 0 && cnt[i] > 0) {
			if (i == 'k' && cnt['k'] <= 1) {
				break;
			}
			cnt['y']--;
			cnt['u']--;
			cnt['k']--;
			cnt[i]--;
			ans++;
		}
	}

	// yu
	for (char i = 'k' + 1; i <= 'u'; i++) {
		while (cnt['y'] > 0 && cnt['u'] > 0 && cnt[i] > 0) { 
			if (i == 'u' && cnt['u'] <= 1) {
				break;
			}
			cnt['y']--;
			cnt['u']--;
			cnt[i]--;
			ans++;
		}
	}

	// y
	for (char i = 'u' + 1; i <= 'y'; i++) {
		while (cnt['y'] > 0 && cnt[i] > 0) { 
			if (i == 'y' && cnt['y'] <= 1) {
				break;
			}
			cnt['y']--;
			cnt[i]--;
			ans++;
		}
	}

	ans += cnt['z'];

	cout << ans << endl;
}
0