結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー Mafuyu KamonoMafuyu Kamono
提出日時 2019-06-22 15:35:14
言語 Go
(1.22.1)
結果
AC  
実行時間 230 ms / 5,000 ms
コード長 815 bytes
コンパイル時間 9,666 ms
コンパイル使用メモリ 207,508 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-08-27 02:52:08
合計ジャッジ時間 12,632 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,384 KB
testcase_01 AC 222 ms
7,940 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 222 ms
7,936 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 134 ms
5,700 KB
testcase_15 AC 54 ms
4,380 KB
testcase_16 AC 171 ms
7,936 KB
testcase_17 AC 51 ms
4,380 KB
testcase_18 AC 162 ms
7,932 KB
testcase_19 AC 120 ms
5,688 KB
testcase_20 AC 230 ms
7,936 KB
testcase_21 AC 7 ms
4,384 KB
testcase_22 AC 79 ms
5,656 KB
testcase_23 AC 205 ms
7,928 KB
testcase_24 AC 213 ms
7,924 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; 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