結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー 👑 tatt61880tatt61880
提出日時 2021-03-18 22:22:05
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 456 ms / 2,000 ms
コード長 872 bytes
コンパイル時間 3,344 ms
コンパイル使用メモリ 160,160 KB
実行使用メモリ 22,460 KB
最終ジャッジ日時 2023-10-14 17:41:11
合計ジャッジ時間 26,710 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,480 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,356 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 449 ms
21,360 KB
testcase_19 AC 408 ms
20,912 KB
testcase_20 AC 220 ms
13,528 KB
testcase_21 AC 28 ms
5,148 KB
testcase_22 AC 242 ms
14,324 KB
testcase_23 AC 21 ms
4,808 KB
testcase_24 AC 331 ms
17,744 KB
testcase_25 AC 223 ms
14,060 KB
testcase_26 AC 70 ms
7,064 KB
testcase_27 AC 21 ms
4,788 KB
testcase_28 AC 427 ms
22,460 KB
testcase_29 AC 455 ms
22,168 KB
testcase_30 AC 450 ms
22,056 KB
testcase_31 AC 451 ms
22,148 KB
testcase_32 AC 435 ms
22,168 KB
testcase_33 AC 429 ms
22,368 KB
testcase_34 AC 445 ms
22,444 KB
testcase_35 AC 454 ms
22,116 KB
testcase_36 AC 438 ms
22,376 KB
testcase_37 AC 456 ms
22,252 KB
testcase_38 AC 427 ms
22,268 KB
testcase_39 AC 452 ms
22,256 KB
testcase_40 AC 425 ms
22,068 KB
testcase_41 AC 453 ms
22,280 KB
testcase_42 AC 452 ms
22,324 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,352 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
		if(me.a < (t $ C).a)
			ret - 1
		elif(me.a > (t $ C).a)
			ret 1
		end if
		ret 0
	end func
end class
0