結果

問題 No.73 helloworld
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-11 10:59:57
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,067 bytes
コンパイル時間 11,459 ms
コンパイル使用メモリ 210,600 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 12:08:07
合計ジャッジ時間 12,570 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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