結果

問題 No.145 yukiover
ユーザー masamasa
提出日時 2015-09-24 16:07:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,634 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 64,248 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 14:48:45
合計ジャッジ時間 1,623 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n;
	string s;
	vector<int> chars(255, 0);

	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		chars[s[i]]++;
	}

	int ans = 0;
	int val;

	// yukia - yukih
	for (char c = 'a'; c < 'i'; c++) {
		val = min({chars['y'], chars['u'], chars['k'], chars['i'], chars[c]});
		ans += val;
		chars['y'] -= val;
		chars['u'] -= val;
		chars['k'] -= val;
		chars['i'] -= val;
		chars[c] -= val;
	}

	// yukii
	val = min({chars['y'], chars['u'], chars['k'], chars['i'] / 2});
	ans += val;
	chars['y'] -= val;
	chars['u'] -= val;
	chars['k'] -= val;
	chars['i'] -= val * 2;

	// yukj
	for (char c = 'j'; c < 'k'; c++) {

		val = min({chars['y'], chars['u'], chars['k'], chars[c]});
		ans += val;
		chars['y'] -= val;
		chars['u'] -= val;
		chars['k'] -= val;
		chars[c] -= val;
	}

	// yukk
	val = min({chars['y'], chars['u'], chars['k'] / 2});
	ans += val;
	chars['y'] -= val;
	chars['u'] -= val;
	chars['k'] -= val * 2;

	// yul - yut
	for (char c = 'l'; c < 't'; c++) {
		val = min({chars['y'], chars['u'], chars[c]});
		ans += val;
		chars['y'] -= val;
		chars['u'] -= val;
		chars[c] -= val;
	}

	// yuu
	val = min(chars['y'], chars['u'] / 2);
	ans += val;
	chars['y'] -= val;
	chars['u'] -= val * 2;

	// yv - yx
	for (char c = 'v'; c < 'y'; c++) {
		val = min(chars['y'], chars[c]);
		ans += val;
		chars['y'] -= val;
		chars[c] -= val;
	}

	// yy
	val = chars['y'] / 2;
	ans += val;
	chars['y'] -= val * 2;

	// z
	ans += chars['z'];
	chars['z'] = 0;

	cout << ans << endl;
	return 0;
}
0