結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
15,684 KB
testcase_01 AC 37 ms
9,648 KB
testcase_02 AC 26 ms
7,856 KB
testcase_03 AC 35 ms
9,420 KB
testcase_04 AC 18 ms
6,352 KB
testcase_05 AC 89 ms
18,700 KB
testcase_06 AC 76 ms
16,636 KB
testcase_07 AC 46 ms
11,484 KB
testcase_08 AC 10 ms
5,200 KB
testcase_09 AC 29 ms
8,296 KB
testcase_10 AC 57 ms
13,300 KB
testcase_11 AC 54 ms
12,632 KB
testcase_12 AC 67 ms
14,672 KB
testcase_13 AC 13 ms
6,212 KB
testcase_14 AC 6 ms
4,600 KB
testcase_15 AC 78 ms
16,724 KB
testcase_16 AC 91 ms
19,372 KB
testcase_17 AC 75 ms
15,952 KB
testcase_18 AC 25 ms
7,732 KB
testcase_19 AC 77 ms
16,508 KB
testcase_20 AC 93 ms
19,520 KB
testcase_21 AC 93 ms
19,444 KB
testcase_22 AC 93 ms
19,440 KB
testcase_23 AC 94 ms
19,448 KB
testcase_24 AC 94 ms
19,460 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