結果

問題 No.73 helloworld
コンテスト
ユーザー 🍡yurahuna
提出日時 2016-04-28 15:59:19
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 97 ms / 5,000 ms
コード長 846 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 620 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2026-03-19 02:03:54
合計ジャッジ時間 2,736 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def nC2(n):
    return n * (n - 1) // 2


N = 26

li = [chr(ord('a') + i) for i in range(N)]
c = [int(input()) for i in range(N)]

chrs = set("helloworld")
dic = {}

for x in chrs:
    dic[x] = c[ord(x) - ord('a')]

ans = 1
for x, n in dic.items():
    if x == 'l':
        if n < 3:
            print(0)
            exit()
        t = 1
        rest = n - 3
        for i in range(rest + 1):  # 余ったlをどう割り振るか
            t = max(t, nC2(i + 2) * (1 + rest - i))
        ans *= t
    elif x == 'o':
        if n < 2:
            print(0)
            exit()
        t = 1
        rest = n - 2
        for i in range(rest + 1):  # 余ったlをどう割り振るか
            t = max(t, (i + 1) * (1 + rest - i))
        ans *= t
    else:
        if n < 1:
            print(0)
            exit()
        ans *= n
print(ans)
0