結果

問題 No.2746 Bicolor Pyramid
ユーザー shobonvipshobonvip
提出日時 2024-04-21 06:46:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,137 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 59,168 KB
最終ジャッジ日時 2024-04-21 06:46:08
合計ジャッジ時間 4,042 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
57,232 KB
testcase_01 AC 40 ms
57,944 KB
testcase_02 WA -
testcase_03 AC 42 ms
57,716 KB
testcase_04 AC 40 ms
57,128 KB
testcase_05 AC 42 ms
57,712 KB
testcase_06 AC 46 ms
58,268 KB
testcase_07 AC 42 ms
57,400 KB
testcase_08 AC 41 ms
57,816 KB
testcase_09 AC 97 ms
59,168 KB
testcase_10 AC 107 ms
57,328 KB
testcase_11 AC 100 ms
57,652 KB
testcase_12 AC 101 ms
57,368 KB
testcase_13 AC 107 ms
57,532 KB
testcase_14 AC 43 ms
57,188 KB
testcase_15 AC 119 ms
58,788 KB
testcase_16 AC 57 ms
57,708 KB
testcase_17 AC 70 ms
57,592 KB
testcase_18 AC 76 ms
57,636 KB
testcase_19 AC 59 ms
57,408 KB
testcase_20 AC 57 ms
57,772 KB
testcase_21 AC 56 ms
57,560 KB
testcase_22 AC 64 ms
57,588 KB
testcase_23 AC 65 ms
57,840 KB
testcase_24 AC 72 ms
57,940 KB
testcase_25 AC 63 ms
58,396 KB
testcase_26 AC 54 ms
57,668 KB
testcase_27 AC 92 ms
58,652 KB
testcase_28 AC 87 ms
57,152 KB
testcase_29 AC 56 ms
58,916 KB
testcase_30 AC 58 ms
57,392 KB
testcase_31 AC 73 ms
57,648 KB
testcase_32 AC 56 ms
57,568 KB
testcase_33 AC 53 ms
58,848 KB
testcase_34 AC 100 ms
57,452 KB
testcase_35 AC 91 ms
57,996 KB
testcase_36 AC 99 ms
58,324 KB
testcase_37 AC 100 ms
57,436 KB
権限があれば一括ダウンロードができます

ソースコード

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())

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(max(0,av-r-b), min(r+1, max(0,av-r-b)+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