結果

問題 No.145 yukiover
ユーザー HachimoriHachimori
提出日時 2015-02-06 00:37:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,581 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 60,044 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 13:28:26
合計ジャッジ時間 1,452 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
    
    for (int i = 'y' + 1; i <= 'z'; ++i) {
        int nUse = cnt[i];
        ans += nUse;
        cnt[i] -= nUse;
    }
    
    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;
    }

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

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

    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;
    
    // yuu
    nUse = min(cnt[(int)'y'], cnt[(int)'u'] / 2);
    ans += nUse;
    cnt[(int)'y'] -= nUse;
    cnt[(int)'u'] -= nUse * 2;

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

    cout << ans << endl;
}


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