結果

問題 No.145 yukiover
ユーザー hogeover30hogeover30
提出日時 2015-02-06 00:17:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,408 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 61,424 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 13:23:15
合計ジャッジ時間 1,451 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 3 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) if (i!='y' and i!='u' and i!='k' and i!='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<'z';++i) if (i!='y' and i!='u' and i!='k' and i!='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;
    }
}
0