結果

問題 No.609 Noelちゃんと星々
ユーザー 👑 tatt61880tatt61880
提出日時 2020-04-05 02:19:45
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 2,739 ms
コンパイル使用メモリ 149,032 KB
実行使用メモリ 19,776 KB
最終ジャッジ日時 2024-09-16 10:29:13
合計ジャッジ時間 6,076 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
15,956 KB
testcase_01 AC 34 ms
10,076 KB
testcase_02 AC 24 ms
7,928 KB
testcase_03 AC 33 ms
9,376 KB
testcase_04 AC 17 ms
6,496 KB
testcase_05 AC 83 ms
18,756 KB
testcase_06 AC 71 ms
16,572 KB
testcase_07 AC 43 ms
11,300 KB
testcase_08 AC 10 ms
5,528 KB
testcase_09 AC 28 ms
8,636 KB
testcase_10 AC 54 ms
13,196 KB
testcase_11 AC 50 ms
12,344 KB
testcase_12 AC 63 ms
14,948 KB
testcase_13 AC 13 ms
6,100 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 74 ms
17,048 KB
testcase_16 AC 84 ms
19,208 KB
testcase_17 AC 68 ms
15,964 KB
testcase_18 AC 24 ms
7,772 KB
testcase_19 AC 72 ms
16,700 KB
testcase_20 AC 89 ms
19,776 KB
testcase_21 AC 91 ms
19,648 KB
testcase_22 AC 89 ms
19,776 KB
testcase_23 AC 87 ms
19,776 KB
testcase_24 AC 87 ms
19,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

var y: []int
func main()
	var n: int :: cui@input().toInt(&)
	var ss: [][]char :: cui@input().split(" ")
	do @y :: #[n]int
	for i(0, n - 1)
		do @y[i] :: ss[i].toInt(&)
	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