結果
問題 |
No.145 yukiover
|
ユーザー |
|
提出日時 | 2015-02-06 00:37:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,581 bytes |
コンパイル時間 | 529 ms |
コンパイル使用メモリ | 58,076 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 09:07:54 |
合計ジャッジ時間 | 1,444 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; for (int i = 'y' + 1; i <= 'z'; ++i) { int nUse = cnt[i]; ans += nUse; cnt[i] -= nUse; } 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; } 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; } 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; } int nUse; // yukk nUse = min(min(cnt[(int)'y'], cnt[(int)'u']), cnt[(int)'k'] / 2); ans += nUse; cnt[(int)'y'] -= nUse; cnt[(int)'u'] -= nUse; cnt[(int)'k'] -= nUse * 2; // yuu nUse = min(cnt[(int)'y'], cnt[(int)'u'] / 2); ans += nUse; cnt[(int)'y'] -= nUse; cnt[(int)'u'] -= nUse * 2; // yy nUse = cnt[(int)'y'] / 2; ans += nUse; cnt[(int)'y'] -= nUse * 2; cout << ans << endl; } int main() { read(); work(); return 0; }