結果

問題 No.2746 Bicolor Pyramid
ユーザー tassei903tassei903
提出日時 2024-04-17 03:57:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 65,792 KB
最終ジャッジ日時 2024-04-17 15:24:07
合計ジャッジ時間 2,241 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
51,968 KB
testcase_01 AC 31 ms
51,968 KB
testcase_02 AC 34 ms
52,608 KB
testcase_03 AC 33 ms
52,352 KB
testcase_04 AC 34 ms
51,968 KB
testcase_05 AC 38 ms
59,008 KB
testcase_06 AC 38 ms
60,160 KB
testcase_07 AC 45 ms
65,792 KB
testcase_08 AC 45 ms
64,896 KB
testcase_09 AC 31 ms
51,968 KB
testcase_10 AC 33 ms
52,224 KB
testcase_11 AC 30 ms
52,096 KB
testcase_12 AC 33 ms
52,224 KB
testcase_13 AC 35 ms
52,352 KB
testcase_14 AC 31 ms
52,224 KB
testcase_15 AC 31 ms
51,840 KB
testcase_16 WA -
testcase_17 AC 30 ms
52,352 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 32 ms
51,840 KB
testcase_27 AC 31 ms
52,480 KB
testcase_28 AC 31 ms
52,224 KB
testcase_29 AC 29 ms
51,968 KB
testcase_30 AC 29 ms
51,840 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 29 ms
52,480 KB
testcase_34 WA -
testcase_35 AC 31 ms
51,968 KB
testcase_36 AC 29 ms
51,968 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

R, B = map(int, input().split())

if R > B:
    R, B = B, R
def f(R, B):
    dp = [0 for _ in range(R + 1)]
    dp[0] = 1
    k = 1
    z = 0
    while True:
        flag = False
        ndp = [0 for _ in range(R + 1)]
        dp, ndp = ndp, dp
        for i in range(R + 1):
            if ndp[i] == 0:
                continue
            j = z - i
            if i + k**2 <= R and j <= B:
                dp[i + k**2] = 1
                flag = True
            if i <= R and j + k**2 <= B:
                dp[i] = 1
                flag = True
        if flag:
            z += k ** 2
            k += 1
        else:
            break

    return k - 1

def h(x):
    ok = 0
    ng = 10**18
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if mid * (mid + 1) * (2 * mid + 1) // 6 <= x:
            ok = mid
        else:
            ng = mid
    return ok

if B <= 10000:
    print(f(R, B))
else:
    print(h(R + B))
0