結果

問題 No.349 干支の置き物
ユーザー t_murano
提出日時 2016-05-14 14:40:30
言語 Go
(1.23.4)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 14,029 ms
コンパイル使用メモリ 230,500 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 07:32:26
合計ジャッジ時間 15,010 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func maxCount(counter map[string]int) int {
	maxCount := 0
	for _, v := range counter {
		if v > maxCount {
			maxCount = v
		}
	}
	return maxCount
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	n := nextInt(sc)
	counter := make(map[string]int)
	for i := 0; i < n; i++ {
		zodiac := nextString(sc)
		counter[zodiac] += 1
	}
	mc := maxCount(counter)
	if mc > (n+1)/2 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}
0