結果

問題 No.145 yukiover
ユーザー greentea011greentea011
提出日時 2019-04-09 15:33:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,725 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 42,940 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 15:52:18
合計ジャッジ時間 2,031 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <algorithm>

int main() {
    int a[9] = {0};
    int n;
    char c;
    scanf("%d\n",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&c);
        if      (c <= 'h') a[0]++;
        else if (c == 'i') a[1]++;
        else if (c == 'j') a[2]++;
        else if (c == 'k') a[3]++;
        else if (c <= 't') a[4]++;
        else if (c == 'u') a[5]++;
        else if (c <= 'x') a[6]++;
        else if (c == 'y') a[7]++;
        else               a[8]++;
    }
    int happy=a[8];
    a[8]=0;
    if (a[7] && a[6]) {
        int dd=std::min({a[7],a[6]});
        happy+=dd;
        a[7]-=dd;
        a[6]-=dd;
    }
    if (a[7] && a[5] && a[4]) {
        int dd=std::min({a[7],a[5],a[4]});
        happy+=dd;
        a[7]-=dd;
        a[5]-=dd;
        a[4]-=dd;
    }
    if (a[7] && a[5] && a[3] && a[2]) {
        int dd=std::min({a[7],a[5],a[3],a[2]});
        happy+=dd;
        a[7]-=dd;
        a[5]-=dd;
        a[3]-=dd;
        a[2]-=dd;
    }
    if (a[7] && a[5] && a[3] && a[1] && a[0]) {
        int dd=std::min({a[7],a[5],a[3],a[1],a[0]});
        happy+=dd;
        a[7]-=dd;
        a[5]-=dd;
        a[3]-=dd;
        a[1]-=dd;
        a[0]-=dd;
    }
    if (a[7] && a[5] && a[3] && (a[1]>=2)) {
        int dd=std::min({a[7],a[5],a[3],a[1]/2});
        happy+=dd;
        a[7]-=dd;
        a[5]-=dd;
        a[3]-=dd;
        a[1]-=(2*dd);
    }
    if (a[7] && a[5] && (a[3]>=2)) {
        int dd=std::min({a[7],a[5],a[3]/2});
        happy+=dd;
        a[7]-=dd;
        a[5]-=dd;
        a[3]-=(2*dd);
    }
    if (a[7] && (a[5]>=2)) {
        int dd=std::min({a[7],a[5]/2});
        happy+=dd;
        a[7]-=dd;
        a[5]-=(2*dd);
    }

    printf ("%d\n",happy);
}
0