結果

問題 No.73 helloworld
ユーザー なおなお
提出日時 2014-11-21 00:22:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,144 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 145,740 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-30 22:00:53
合計ジャッジ時間 1,929 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
#define REPEAT(i, k, n)     for(int(i)=(k);(i)<((k)+(n));++(i))

int C[27],U[27];

int comb(int n, int m){
    int k = 1;
    for(int i = 0; i < m; i++){
        k *= (n-i);
    }
    for(int i = 2; i <= m; i++){
        k /= i;
    }
    return k;
}

int main(){
    const string s = "helloworld";
    REP(i,27){
        cin >> C[i];
    }
    REP(i,(int)s.size()){
        int c = s[i]-'a';
        U[c]++;
        if(C[c]-U[c] < 0){
            cout << 0 << endl;
            return 0;
        }
    }
    int k = 1;
    REP(i,27){
        if(!U[i]) continue;
        if(i == ('l'-'a')){
        } else if(i == ('o'-'a')){
        } else {
            k *= C[i];
        }
    }
    int maxv = 0;
    int i = 'l'-'a';
    REP(j,C[i]-U[i]+1){
        maxv = max(maxv, k*comb(j+2,2)*(C[i]-U[i]-j+1));
    }
    k = maxv;

    i = 'o'-'a';
    REP(j,C[i]-U[i]+1){
        maxv = max(maxv, k*(j+1)*(C[i]-U[i]-j+1));
    }

    cout << maxv << endl;
    return 0;
}
0