結果
| 問題 |
No.145 yukiover
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-06 00:47:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,466 bytes |
| コンパイル時間 | 546 ms |
| コンパイル使用メモリ | 58,644 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 09:20:05 |
| 合計ジャッジ時間 | 1,449 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 11 WA * 9 |
ソースコード
#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 = '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;
}