結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー tyochiaityochiai
提出日時 2015-02-07 19:02:45
言語 Go
(1.22.1)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 487 bytes
コンパイル時間 11,289 ms
コンパイル使用メモリ 213,924 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-09-08 14:20:37
合計ジャッジ時間 13,696 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
4,384 KB
testcase_01 AC 268 ms
7,928 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 272 ms
7,944 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 160 ms
5,700 KB
testcase_15 AC 65 ms
4,376 KB
testcase_16 AC 208 ms
7,932 KB
testcase_17 AC 61 ms
4,380 KB
testcase_18 AC 198 ms
7,928 KB
testcase_19 AC 142 ms
5,688 KB
testcase_20 AC 267 ms
7,940 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 95 ms
5,664 KB
testcase_23 AC 248 ms
7,940 KB
testcase_24 AC 260 ms
7,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"sort"
)

func resolve(N int, L []int) int {
	ret := L[0]
	tmp := L[0]
	max := 0
	cnt := 1
	for i := 1; i < N; i++ {
		if L[i] == tmp {
			cnt += 1
			continue
		}
		if cnt >= max {
			max = cnt
			ret = tmp
		}
		tmp = L[i]
		cnt = 1
	}
	if cnt >= max {
		return L[N-1]
	}
	return ret
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	L := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &L[i])
	}
	sort.Ints(L)
	fmt.Println(resolve(N, L))
}
0