結果

問題 No.2746 Bicolor Pyramid
ユーザー shobonvipshobonvip
提出日時 2024-04-21 06:50:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,145 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 67,140 KB
最終ジャッジ日時 2024-04-21 06:50:18
合計ジャッジ時間 4,101 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
57,088 KB
testcase_01 AC 44 ms
57,216 KB
testcase_02 WA -
testcase_03 AC 46 ms
57,088 KB
testcase_04 AC 47 ms
57,472 KB
testcase_05 AC 44 ms
57,088 KB
testcase_06 AC 45 ms
57,472 KB
testcase_07 AC 45 ms
57,216 KB
testcase_08 AC 45 ms
57,088 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 46 ms
56,832 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def var_calc(n):
	var = 0
	for i in range(1, n + 1):
		var += i * i
	return var

def shirabe(n):
	var = 0
	for i in range(1, n + 1):
		var += i * i
	a = [0] * (var + 1)
	a[0] = 1
	for i in range(1, n + 1):
		b = a[::]
		for j in range(var + 1):
			if i * i + j <= var and a[j]:
				b[i * i + j] = 1
		a = b
	tar = []
	for i in range(var + 1):
		if a[i] == 0:
			tar.append(i)
	return tar

	
# 1 + 4 + 9 + 16 + 25 + 36


#for n in range(1, 11):
#	print(n, shirabe(n), var_calc(n))

umekomi = [2, 3, 6, 7, 8, 11, 12, 15, 18, 19, 22, 23, 24, 27, 28, 31, 32, 33, 43, 44, 47, 48, 60, 67,
72, 76, 92, 96, 108, 112, 128]

r, b = map(int,input().split())

assert r <= 10**6 and b <= 10**6

ub = 2 * 10 ** 6
lb = 1
while ub - lb > 1:
	t = (ub + lb) // 2
	av = var_calc(t)
	if r + b < av:
		ub = t
		continue
	norep = set(umekomi)
	for i in umekomi:
		norep.add(av - i)
	if r >= av or b >= av:
		lb = t
		continue
	good = 0
	for i in range(0, min(r+1, 1000)):
		if r - i in norep: continue
		if av - (r - i) > b: continue
		if av - (r - i) < 0: continue
		if av - (r - i) in norep: continue
		good = 1
		break
	if good:
		lb = t
	else:
		ub = t

print(lb)
0