結果

問題 No.73 helloworld
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-11 10:59:40
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,064 bytes
コンパイル時間 10,942 ms
コンパイル使用メモリ 211,208 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 20:04:21
合計ジャッジ時間 11,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"math"
)

func main() {
	var c int

	alpha := make(map[string]int, 0)
	for i := 0; i < 26; i++ {
		_, _ = fmt.Scan(&c)

		alpha[string('a'+i)] = c
	}
	fmt.Println(alpha)

	ans := 1
	for _, c := range "helowrd" {
		switch string(c) {
		case "h", "e", "w", "r", "d":
			if alpha[string(c)] < 1 {
				ans *= 0
			} else {
				ans *= alpha[string(c)]
			}
		case "o":
			if alpha[string(c)] < 2 {
				ans *= 0
			} else {
				p1 := int(math.Ceil(float64(alpha[string(c)]) / 2))
				p2 := alpha[string(c)] / 2
				ans *= p1 * p2
			}
		case "l":
			if alpha[string(c)] < 3 {
				ans *= 0
			} else {
				// lの確率が最大になる組み合わせを探す
				max := 1
				for i := alpha[string(c)] - 3; i >= 0; i-- {
					p1 := 0
					for j := 1; j < i+2; j++ {
						p1 += j
					}
					p2 := alpha[string(c)] - 2 - i

					// fmt.Println(i, p1, p2)

					if p1*p2 > max {
						max = p1 * p2
					} else {
						break
					}
				}

				ans *= max
			}
		}
		// fmt.Println(string(c), alpha[string(c)], ans)
	}

	fmt.Println(ans)
}
0