結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー Mafuyu KamonoMafuyu Kamono
提出日時 2019-06-22 15:32:20
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 817 bytes
コンパイル時間 11,652 ms
コンパイル使用メモリ 213,844 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-08-27 02:51:53
合計ジャッジ時間 12,751 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,376 KB
testcase_01 AC 223 ms
7,936 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 224 ms
7,940 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 134 ms
5,700 KB
testcase_15 AC 56 ms
4,380 KB
testcase_16 AC 174 ms
7,940 KB
testcase_17 AC 54 ms
4,376 KB
testcase_18 AC 161 ms
7,936 KB
testcase_19 AC 121 ms
5,688 KB
testcase_20 AC 224 ms
7,936 KB
testcase_21 AC 6 ms
4,376 KB
testcase_22 AC 78 ms
5,660 KB
testcase_23 AC 207 ms
7,936 KB
testcase_24 AC 229 ms
7,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"sort"
)

type Level struct {
	level int
	vote int
}

type Levels []Level

func(ls Levels) Len() int {
	return len(ls)
}

func(ls Levels) Less(i, j int) bool {
	if ls[i].vote < ls[j].vote {
		return true
	} else if (ls[i].vote == ls[j].vote) && (ls[i].level < ls[j].level) {
		return true
	}
	return false
}

func(ls Levels) Swap(i, j int){
	ls[i], ls[j] = ls[j], ls[i]
}

func main() {
	// memo 値を取り出す
	var N int
	fmt.Scan(&N)

	L := make([]int, N, N)
	for i := 0; i < N-1; i++ {
		fmt.Scan(&L[i])
	}

	// memo 値のcount
	c := make(map[int]int)
	for _, v := range L {
		c[v] += 1
	}

	// memo sort
	var levels Levels
	for k, v := range c {
		levels = append(levels,Level{
			level: k,
			vote: v,
		})
	}
	sort.Sort(sort.Reverse(levels))
	fmt.Println(levels[0].level)
}

0