結果

問題 No.967 引き算をして門松列(その2)
ユーザー 👑 tatt61880tatt61880
提出日時 2020-04-25 16:06:58
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 1,251 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 145,584 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 16:34:39
合計ジャッジ時間 2,600 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 12 ms
4,352 KB
testcase_04 AC 12 ms
4,348 KB
testcase_05 AC 10 ms
4,352 KB
testcase_06 AC 10 ms
4,352 KB
testcase_07 AC 13 ms
4,348 KB
testcase_08 AC 25 ms
4,352 KB
testcase_09 AC 33 ms
4,348 KB
testcase_10 AC 32 ms
4,348 KB
testcase_11 AC 32 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var t: int :: cui@inputInt()
	for(1, t)
		var A: int :: cui@inputInt()
		var B: int :: cui@inputInt()
		var C: int :: cui@inputInt()
		var x: int :: cui@inputInt()
		var y: int :: cui@inputInt()
		var z: int :: cui@inputInt()
		
		; bが最大のとき
		var ans1: int :: -1
		block
			var a: int :: A
			var b: int :: B
			var c: int :: C
			var cnt: int :: 0
			if(a >= b)
				do cnt :+ (a - (b - 1)) * x
				do a :: b - 1
			end if
			if(c >= b)
				do cnt :+ (c - (b - 1)) * z
				do c :: b - 1
			end if
			if(a = c)
				do cnt :+ lib@min(x, z)
				do a :- 1
			end if
			if(a > 0 & c > 0)
				do ans1 :: cnt
			end if
		end block
		
		; bが最小のとき
		var ans2: int :: -1
		block
			var a: int :: A
			var b: int :: B
			var c: int :: C
			var cnt: int :: 0
			if(a = c)
				do cnt :+ lib@min(x, z)
				do a :- 1
			end if
			var target: int :: lib@min(a, c)
			if(b >= target)
				do cnt :+ (b - (target - 1)) * y
				do b :: target - 1
			end if
			if(b > 0)
				do ans2 :: cnt
			end if
		end block
		
		var ans: int :: -1
		if(ans1 >= 0)
			do ans :: ans1
		end if
		if(ans2 >= 0)
			if(ans >= 0)
				do ans :: lib@min(ans, ans2)
			else
				do ans :: ans2
			end if
		end if
		do cui@print("\{ans}\n")
	end for
end func
0