結果
| 問題 |
No.145 yukiover
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-06 00:13:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,318 bytes |
| コンパイル時間 | 435 ms |
| コンパイル使用メモリ | 59,612 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 09:02:06 |
| 合計ジャッジ時間 | 1,141 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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<'y';++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<'z';++i) if (i!='y' and i!='u' and i!='k' and 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;
}
}
hogeover30