結果
問題 |
No.145 yukiover
|
ユーザー |
![]() |
提出日時 | 2015-02-06 00:06:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,274 bytes |
コンパイル時間 | 797 ms |
コンパイル使用メモリ | 59,360 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 09:00:59 |
合計ジャッジ時間 | 1,943 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 WA * 5 |
ソースコード
#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { int n; string s; while (cin>>n>>s) { int a[128]={}; for(char c: s) a[c]++; int res=a['z']; int Y=a['y'], U=a['u'], K=a['k'], I=a['i']; for(int i='v';Y&&i<='x';++i) { int m=min(a[i], Y); res+=m; a[i]-=m; Y-=m; } if (Y and U) { for(int i='k'+1;Y&&U&&i<'u';++i) { int m=min({a[i], Y, U}); res+=m; a[i]-=m; Y-=m; U-=m; } } if (Y and U and K) { for(int i='i'+1;Y&&U&&K&&i<'k';++i) { int m=min({a[i], Y, U, K}); res+=m; a[i]-=m; Y-=m; U-=m; K-=m; } } if (Y and U and K and I) { for(int i='a';Y&&U&&K&&I&&i<'i';++i) { int m=min({a[i], Y, U, K, I}); res+=m; a[i]-=m; Y-=m; U-=m; K-=m; I-=m; } } while (Y and U and K>1) { ++res; --Y, --U, K-=2; } while (Y and U>1) { ++res; --Y, U-=2; } while (Y>1) { ++res; Y-=2; } cout<<res<<endl; } }