結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 13 ms
4,352 KB
testcase_04 AC 13 ms
4,348 KB
testcase_05 AC 14 ms
4,348 KB
testcase_06 AC 14 ms
4,348 KB
testcase_07 AC 16 ms
4,352 KB
testcase_08 AC 29 ms
4,352 KB
testcase_09 AC 37 ms
4,356 KB
testcase_10 AC 40 ms
4,352 KB
testcase_11 AC 39 ms
4,348 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
			; x, yは、A=Cの時以外は使う必要がない。
			if(A = C)
				if(x < y)
					do cnt :+ x
					do A :- 1
					do B :- 1
				else
					do cnt :+ y
					do C :- 1
					do B :- 1
				end if
			end if
			if(A > C)
				if(A >= B)
					do cnt :+ (A - (B - 1)) * z
					do C :- (A - (B - 1))
					do A :- (A - (B - 1))
				end if
			else
				if(C >= B)
					do cnt :+ (C - (B - 1)) * z
					do A :- (C - (B - 1))
					do C :- (C - (B - 1))
				end if
			end if
			if(A > 0 & C > 0 & B > 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(B >= A)
				do cnt :+ (B - (A - 1)) * y
				do C :- (B - (A - 1))
				do B :- (B - (A - 1))
			end if
			if(B >= C)
				do cnt :+ (B - (C - 1)) * x
				do A :- (B - (C - 1))
				do B :- (B - (C - 1))
			end if
			if(A = C)
				if(x < y)
					do cnt :+ x
					do A :- 1
					do B :- 1
				else
					do cnt :+ y
					do B :- 1
					do C :- 1
				end if
			end if
			;do cui@print("\{A} \{B} \{C}\n")
			if(A > 0 & C > 0 & 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