結果
問題 |
No.79 過小評価ダメ・ゼッタイ
|
ユーザー |
|
提出日時 | 2018-03-11 17:50:43 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 960 bytes |
コンパイル時間 | 13,764 ms |
コンパイル使用メモリ | 234,812 KB |
実行使用メモリ | 6,816 KB |
最終ジャッジ日時 | 2024-10-15 00:20:39 |
合計ジャッジ時間 | 14,281 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 8 WA * 14 |
ソースコード
package main import ( "fmt" "strconv" "strings" ) // エントリポイント func main() { input1 := "" fmt.Scan(&input1) input2 := "" fmt.Scan(&input2) fmt.Println(majorityVote(input1, input2)) } // 多数決で一番多いレベルを返す。 func majorityVote(userCount string, vote string) string { const maxLevel = 6 _ = userCount // 配列のサイズを変数で指定することはできないため、スライスを使用する。 // 例) // int := 10 // voteList := [i]int{} // エラー) // non-constant array bound i voteList := [maxLevel]int{} sp := strings.Split(vote, " ") for _, v := range sp { index, _ := strconv.Atoi(v) voteList[index-1]++ } // 配列の中で一番大きい数値のインデックスを返す。 maxIndex := 0 maxNum := 0 for i := 0; i < len(voteList); i++ { if voteList[i] >= maxNum { maxIndex = i maxNum = voteList[i] } } return strconv.Itoa(maxIndex + 1) }