結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,376 KB
testcase_01 AC 234 ms
7,924 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 224 ms
7,944 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 141 ms
5,696 KB
testcase_15 AC 59 ms
4,380 KB
testcase_16 AC 183 ms
7,932 KB
testcase_17 AC 52 ms
4,376 KB
testcase_18 AC 166 ms
7,936 KB
testcase_19 AC 120 ms
5,692 KB
testcase_20 AC 223 ms
7,924 KB
testcase_21 AC 6 ms
4,376 KB
testcase_22 AC 82 ms
5,660 KB
testcase_23 AC 217 ms
7,940 KB
testcase_24 AC 222 ms
7,940 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