結果

問題 No.609 Noelちゃんと星々
ユーザー 👑 tatt61880tatt61880
提出日時 2020-04-25 15:22:42
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 1,911 ms
コンパイル使用メモリ 151,748 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 16:31:19
合計ジャッジ時間 4,301 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
4,352 KB
testcase_01 AC 26 ms
4,352 KB
testcase_02 AC 18 ms
4,352 KB
testcase_03 AC 23 ms
4,352 KB
testcase_04 AC 13 ms
4,352 KB
testcase_05 AC 63 ms
4,352 KB
testcase_06 AC 53 ms
4,348 KB
testcase_07 AC 32 ms
4,348 KB
testcase_08 AC 7 ms
4,348 KB
testcase_09 AC 21 ms
4,348 KB
testcase_10 AC 39 ms
4,348 KB
testcase_11 AC 37 ms
4,348 KB
testcase_12 AC 46 ms
4,352 KB
testcase_13 AC 10 ms
4,352 KB
testcase_14 AC 5 ms
4,352 KB
testcase_15 AC 55 ms
4,352 KB
testcase_16 AC 63 ms
4,348 KB
testcase_17 AC 52 ms
4,352 KB
testcase_18 AC 18 ms
4,348 KB
testcase_19 AC 52 ms
4,348 KB
testcase_20 AC 63 ms
4,348 KB
testcase_21 AC 64 ms
4,348 KB
testcase_22 AC 64 ms
4,352 KB
testcase_23 AC 66 ms
4,348 KB
testcase_24 AC 66 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

var y: []int
func main()
	var n: int :: cui@inputInt()
	do @y :: #[n]int
	for i(0, n - 1)
		do @y[i] :: cui@inputInt()
	end for
	do @y.sort()
	var yMin: int :: @y.min()
	var yMax: int :: @y.max()
	while(yMax - yMin > 2)
		var y1: int :: yMin + (yMax - yMin) * 1 / 3
		var y2: int :: yMin + (yMax - yMin) * 2 / 3
		if(f(y1) > f(y2))
			do yMin :: y1
		else
			do yMax :: y2
		end if
	end while
	
	var ans: int :: [f(yMin), f(yMin + 1), f(yMax + 1), f(yMin + 2)].min()
	do cui@print("\{ans}\n")
	
	func f(y: int): int
		var res: int :: 0
		for i(0, ^@y - 1)
			do res :+ (@y[i] - y).abs()
		end for
		ret res
	end func
end func
0