結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー 👑 tatt61880tatt61880
提出日時 2021-08-20 04:51:51
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 6,626 ms
コンパイル使用メモリ 148,700 KB
実行使用メモリ 22,640 KB
最終ジャッジ日時 2024-04-21 08:08:39
合計ジャッジ時間 25,609 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 393 ms
21,632 KB
testcase_19 AC 366 ms
20,992 KB
testcase_20 AC 183 ms
13,568 KB
testcase_21 AC 27 ms
5,376 KB
testcase_22 AC 202 ms
14,464 KB
testcase_23 AC 19 ms
5,376 KB
testcase_24 AC 268 ms
17,920 KB
testcase_25 AC 193 ms
14,080 KB
testcase_26 AC 65 ms
7,424 KB
testcase_27 AC 19 ms
5,376 KB
testcase_28 AC 377 ms
22,528 KB
testcase_29 AC 369 ms
22,528 KB
testcase_30 AC 360 ms
22,528 KB
testcase_31 AC 384 ms
22,452 KB
testcase_32 AC 362 ms
22,528 KB
testcase_33 AC 381 ms
22,504 KB
testcase_34 AC 361 ms
22,528 KB
testcase_35 AC 379 ms
22,528 KB
testcase_36 AC 395 ms
22,400 KB
testcase_37 AC 371 ms
22,472 KB
testcase_38 AC 392 ms
22,360 KB
testcase_39 AC 382 ms
22,640 KB
testcase_40 AC 385 ms
22,356 KB
testcase_41 AC 391 ms
22,428 KB
testcase_42 AC 382 ms
22,520 KB
testcase_43 AC 1 ms
5,376 KB
testcase_44 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var a: []int :: #[n]int
	for i(0, n - 1)
		do a[i] :: cui@inputInt()
	end for
	
	var mid: int :: 0
	var b: []int :: #[n]int
	for i(0, n - 1)
		do b[i] :: cui@inputInt()
		do mid :+ b[i]
	end for
	do mid :/ 2
	
	var c: []@C :: #[n]@C
	for i(0, n - 1)
		do c[i] :: (#@C).init(a[i], b[i])
	end for
	do c.sort()
	
	var sum: int :: 0
	var x: int :: 0
	for i(0, n - 1)
		do sum :+ c[i].b
		if(sum >= mid)
			do x :: c[i].a
			break i
		end if
	end for
	
	var ans: int :: 0
	for i(0, n - 1)
		do ans :+ c[i].b * (x - c[i].a).abs()
	end for
	
	do cui@print("\{x} \{ans}\n")
end func

class C()
	+var a: int
	+var b: int
	+func init(a: int, b: int): C
		do me.a :: a
		do me.b :: b
		ret me
	end func
	+*func cmp(t: kuin@Class): int
		ret (me.a - (t $ C).a).sign()
	end func
end class
0