結果

問題 No.2746 Bicolor Pyramid
ユーザー 👑 rin204rin204
提出日時 2024-04-21 14:33:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 84,788 KB
最終ジャッジ日時 2024-04-21 14:33:16
合計ジャッジ時間 3,877 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
53,104 KB
testcase_01 AC 31 ms
52,272 KB
testcase_02 AC 31 ms
52,608 KB
testcase_03 AC 32 ms
52,696 KB
testcase_04 AC 31 ms
52,340 KB
testcase_05 AC 30 ms
53,032 KB
testcase_06 AC 35 ms
58,832 KB
testcase_07 AC 34 ms
59,052 KB
testcase_08 AC 35 ms
58,948 KB
testcase_09 AC 77 ms
83,204 KB
testcase_10 AC 71 ms
83,756 KB
testcase_11 AC 73 ms
83,880 KB
testcase_12 AC 78 ms
83,456 KB
testcase_13 AC 76 ms
82,776 KB
testcase_14 AC 34 ms
53,372 KB
testcase_15 AC 72 ms
82,896 KB
testcase_16 AC 96 ms
83,556 KB
testcase_17 AC 77 ms
82,944 KB
testcase_18 AC 75 ms
84,424 KB
testcase_19 AC 76 ms
83,980 KB
testcase_20 AC 75 ms
83,980 KB
testcase_21 AC 73 ms
83,152 KB
testcase_22 AC 75 ms
83,184 KB
testcase_23 AC 78 ms
83,312 KB
testcase_24 AC 77 ms
83,672 KB
testcase_25 AC 75 ms
84,788 KB
testcase_26 AC 74 ms
82,940 KB
testcase_27 AC 74 ms
83,008 KB
testcase_28 AC 74 ms
83,552 KB
testcase_29 AC 74 ms
84,040 KB
testcase_30 AC 98 ms
84,256 KB
testcase_31 AC 80 ms
83,004 KB
testcase_32 AC 80 ms
83,400 KB
testcase_33 AC 82 ms
83,640 KB
testcase_34 AC 81 ms
83,316 KB
testcase_35 AC 83 ms
83,000 KB
testcase_36 AC 75 ms
83,000 KB
testcase_37 AC 74 ms
83,168 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, 100)
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()

if m > 100:
    for i in range(200, len(dp)):
        dp[i] = 1
while r + b > tt and not dp[r]:
    r -= 1

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