結果
| 問題 |
No.145 yukiover
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-06 00:57:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 2,010 bytes |
| コンパイル時間 | 508 ms |
| コンパイル使用メモリ | 58,488 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 09:44:24 |
| 合計ジャッジ時間 | 1,406 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
#include<iostream>
#include<algorithm>
using namespace std;
string s;
void read() {
int n;
cin >> n >> s;
}
void work() {
int cnt[128] = {};
for (int i = 0; i < s.size(); ++i)
++cnt[(int)s[i]];
int ans = 0;
int t;
for (int i = 'a'; i < 'i'; ++i) {
int nUse = min(min(min(min(cnt[(int)'y'], cnt[(int)'u']), cnt[(int)'k']), cnt[(int)'i']), cnt[i]);
ans += nUse;
cnt[(int)'y'] -= nUse;
cnt[(int)'u'] -= nUse;
cnt[(int)'k'] -= nUse;
cnt[(int)'i'] -= nUse;
cnt[i] -= nUse;
}
// yukii
t = min(min(min(cnt[(int)'y'], cnt[(int)'u']), cnt[(int)'k']), cnt[(int)'i'] / 2);
ans += t;
cnt[(int)'y'] -= t;
cnt[(int)'u'] -= t;
cnt[(int)'k'] -= t;
cnt[(int)'i'] -= t * 2;
for (int i = 'i' + 1; i < 'k'; ++i) {
int nUse = min(min(min(cnt[(int)'y'], cnt[(int)'u']), cnt[(int)'k']), cnt[i]);
ans += nUse;
cnt[(int)'y'] -= nUse;
cnt[(int)'u'] -= nUse;
cnt[(int)'k'] -= nUse;
cnt[i] -= nUse;
}
// yukk
t = min(min(cnt[(int)'y'], cnt[(int)'u']), cnt[(int)'k'] / 2);
ans += t;
cnt[(int)'y'] -= t;
cnt[(int)'u'] -= t;
cnt[(int)'k'] -= t * 2;
for (int i = 'k' + 1; i < 'u'; ++i) {
int nUse = min(min(cnt[(int)'y'], cnt[(int)'u']), cnt[i]);
ans += nUse;
cnt[(int)'y'] -= nUse;
cnt[(int)'u'] -= nUse;
cnt[i] -= nUse;
}
// yuu
t = min(cnt[(int)'y'], cnt[(int)'u'] / 2);
ans += t;
cnt[(int)'y'] -= t;
cnt[(int)'u'] -= t * 2;
for (int i = 'u' + 1; i < 'y'; ++i) {
int nUse = min(cnt[(int)'y'], cnt[i]);
ans += nUse;
cnt[(int)'y'] -= nUse;
cnt[i] -= nUse;
}
// yy
t = cnt[(int)'y'] / 2;
ans += t;
cnt[(int)'y'] -= t * 2;
// z
ans += cnt[(int)'z'];
cout << ans << endl;
}
int main() {
read();
work();
return 0;
}