結果

問題 No.2746 Bicolor Pyramid
ユーザー 👑 rin204rin204
提出日時 2024-04-20 14:33:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 60,080 KB
最終ジャッジ日時 2024-04-20 14:33:40
合計ジャッジ時間 2,970 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,472 KB
testcase_01 AC 38 ms
52,500 KB
testcase_02 AC 37 ms
52,492 KB
testcase_03 AC 38 ms
53,092 KB
testcase_04 AC 38 ms
53,012 KB
testcase_05 AC 38 ms
52,952 KB
testcase_06 AC 42 ms
59,568 KB
testcase_07 AC 42 ms
59,356 KB
testcase_08 AC 42 ms
59,080 KB
testcase_09 AC 46 ms
59,264 KB
testcase_10 AC 43 ms
58,888 KB
testcase_11 AC 42 ms
58,708 KB
testcase_12 AC 42 ms
59,372 KB
testcase_13 AC 43 ms
59,036 KB
testcase_14 AC 38 ms
53,312 KB
testcase_15 AC 53 ms
58,912 KB
testcase_16 AC 41 ms
58,428 KB
testcase_17 AC 41 ms
58,312 KB
testcase_18 AC 42 ms
58,500 KB
testcase_19 AC 43 ms
58,700 KB
testcase_20 AC 43 ms
58,880 KB
testcase_21 AC 41 ms
58,404 KB
testcase_22 AC 42 ms
58,296 KB
testcase_23 AC 42 ms
58,356 KB
testcase_24 AC 41 ms
60,080 KB
testcase_25 AC 41 ms
59,104 KB
testcase_26 AC 41 ms
59,116 KB
testcase_27 AC 41 ms
58,744 KB
testcase_28 AC 42 ms
58,292 KB
testcase_29 AC 42 ms
58,864 KB
testcase_30 AC 43 ms
59,232 KB
testcase_31 AC 42 ms
59,368 KB
testcase_32 AC 42 ms
58,456 KB
testcase_33 AC 42 ms
58,416 KB
testcase_34 AC 41 ms
59,344 KB
testcase_35 AC 42 ms
59,992 KB
testcase_36 AC 68 ms
58,800 KB
testcase_37 AC 41 ms
59,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

r, b = map(int, input().split())
t = r + b
if r > b:
    r, b = b, r

l_ = 0
r_ = t + 1
while r_ - l_ > 1:
    m = (l_ + r_) // 2
    if m * (m + 1) * (2 * m + 1) // 6 <= t:
        l_ = m
    else:
        r_ = m

m = l_
tt = l_ * (l_ + 1) * (2 * l_ + 1) // 6

dp = [1]
x = min(m, 20)
for x in range(1, x + 1):
    t = x * x
    dp += [0] * t
    for i in range(len(dp) - 1, t - 1, -1):
        dp[i] |= dp[i - t]

if r > len(dp):
    print(m)
    exit()

while r + b > tt and not dp[r]:
    r -= 1

if dp[r]:
    print(m)
else:
    print(m - 1)
0