結果
問題 | No.145 yukiover |
ユーザー |
![]() |
提出日時 | 2015-02-07 01:40:38 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 1,470 bytes |
コンパイル時間 | 513 ms |
コンパイル使用メモリ | 61,864 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 10:30:20 |
合計ジャッジ時間 | 1,400 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include <iostream> #include <algorithm> #include <sstream> #include <cstdio> using namespace std; int main(int argc, char *argv[]) { string s; getline(cin, s); int N = atoi(s.c_str()); getline(cin, s); int cnt[256] = {}; for (char c : s) { cnt[c] += 1; } int ans = cnt['z']; cnt['z'] = 0; while (cnt['y'] && cnt['u'] && cnt['k'] && cnt['i']) { int i; for (i = 'a'; i < 'i'; ++i) { if (cnt[i]) { break; } } if (i >= 'i') { break; } ++ans; cnt['y'] -= 1, cnt['u'] -= 1, cnt['k'] -= 1, cnt['i'] -= 1, cnt[i] -= 1; } while (cnt['y'] && cnt['u'] && cnt['k'] && cnt['i'] >= 2) { ++ans; cnt['y'] -= 1, cnt['u'] -= 1, cnt['k'] -= 1, cnt['i'] -= 2; } while (cnt['y'] && cnt['u'] && cnt['k'] && cnt['j']) { ++ans; cnt['y'] -= 1, cnt['u'] -= 1, cnt['k'] -= 1, cnt['j'] -= 1; } while (cnt['y'] && cnt['u'] && cnt['k'] >= 2) { ++ans; cnt['y'] -= 1, cnt['u'] -= 1, cnt['k'] -= 2; } while (cnt['y'] && cnt['u']) { int i; for (i = 'l'; i < 'u'; ++i) { if (cnt[i]) { break; } } if (i >= 'u') { break; } ++ans; cnt['y'] -= 1, cnt['u'] -= 1, cnt[i] -= 1; } while (cnt['y'] && cnt['u'] >= 2) { ++ans; cnt['y'] -= 1, cnt['u'] -= 2; } while (cnt['y']) { int i; for (i = 'v'; i < 'y'; ++i) { if (cnt[i]) { break; } } if (i >= 'y') { break; } ++ans; cnt['y'] -= 1, cnt[i] -= 1; } while (cnt['y'] >= 2) { cnt['y'] -= 2; ++ans; } cout << ans << endl; return 0; }