結果

問題 No.968 引き算をして門松列(その3)
ユーザー 👑 tatt61880tatt61880
提出日時 2020-04-25 16:08:38
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,742 bytes
コンパイル時間 3,562 ms
コンパイル使用メモリ 146,360 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 16:34:51
合計ジャッジ時間 3,078 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 12 ms
4,348 KB
testcase_04 AC 13 ms
4,352 KB
testcase_05 AC 12 ms
4,348 KB
testcase_06 AC 13 ms
4,348 KB
testcase_07 AC 16 ms
4,348 KB
testcase_08 AC 27 ms
4,352 KB
testcase_09 AC 36 ms
4,352 KB
testcase_10 AC 37 ms
4,348 KB
testcase_11 AC 35 ms
4,352 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
			; 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 :: A
			var b: int :: B
			var c: int :: C
			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