結果

問題 No.73 helloworld
ユーザー Tatsu_mr
提出日時 2024-10-13 15:29:24
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,056 bytes
コンパイル時間 3,072 ms
コンパイル使用メモリ 250,640 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-13 15:29:28
合計ジャッジ時間 3,538 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define For(i, a, b) for(long long i = a; i < b; i++)
#define rep(i, n) For(i, 0, n)
#define rFor(i, a, b) for(long long i = a; i >= b; i--)
#define ALL(v) (v).begin(), (v).end()
#define rALL(v) (v).rbegin(), (v).rend()
using namespace std;

using lint = long long;
using ld = long double;

int main() {
    vector<lint> c(26);
    set<char> st = {'h', 'e', 'w', 'r', 'd'};
    rep(i, 26) {
        cin >> c[i];
    }
    auto choose = [&](lint x) -> lint {
        return x * (x - 1LL) / 2LL;
    };
    auto mxl = [&](lint x) -> lint {
        lint res = 0;
        for (lint i = 2; (x - i) >= 1; i++) {
            res = max(res, choose(i) * (x - i));
        }
        return res;
    };
    auto mxo = [&](lint x) -> lint {
        lint res = 0;
        for (lint i = 1; i < x; i++) {
            res = max(res, i * (x - i));
        }
        return res;
    };
    lint ans = 1;
    for (char ch : st) {
        ans *= c[ch - 'a'];
    }
    ans *= mxl(c['l' - 'a']);
    ans *= mxo(c['o' - 'a']);
    cout << ans << endl;
}
0