結果

問題 No.145 yukiover
ユーザー HachimoriHachimori
提出日時 2015-02-06 00:45:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,491 bytes
コンパイル時間 976 ms
コンパイル使用メモリ 60,940 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-05 13:35:20
合計ジャッジ時間 1,656 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
    
    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;
    
    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;
    }

    // yuu
    nUse = min(cnt[(int)'y'], cnt[(int)'u'] / 2);
    ans += nUse;
    cnt[(int)'y'] -= nUse;
    cnt[(int)'u'] -= nUse * 2;

    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;
    }

    // yy
    nUse = cnt[(int)'y'] / 2;
    ans += nUse;
    cnt[(int)'y'] -= nUse * 2;

    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;
    }

    
    ans += cnt[(int)'z'];
    
    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}
0