結果

問題 No.967 引き算をして門松列(その2)
ユーザー 👑 tatt61880tatt61880
提出日時 2020-01-13 21:17:37
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,312 bytes
コンパイル時間 2,413 ms
コンパイル使用メモリ 157,600 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 15:49:07
合計ジャッジ時間 3,031 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

func main()
	var T: int :: cui@input().toInt(&)
	for t(1, T)
		var ss: [][]char :: cui@input().split(" ")
		var AA: int :: ss[0].toInt(&)
		var BB: int :: ss[1].toInt(&)
		var CC: int :: ss[2].toInt(&)
		var x: int :: ss[3].toInt(&)
		var y: int :: ss[4].toInt(&)
		var z: int :: ss[5].toInt(&)
		
		; Bが最大のとき
		var ans1: int :: -1
		block
			var A: int :: AA
			var B: int :: BB
			var C: int :: CC
			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 :: AA
			var B: int :: BB
			var C: int :: CC
			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