結果

問題 No.2510 Six Cube Sum Counting
コンテスト
ユーザー detteiuu
提出日時 2026-07-03 22:42:55
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
MLE  
実行時間 -
コード長 1,534 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 240 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 517,096 KB
最終ジャッジ日時 2026-07-03 22:44:14
合計ジャッジ時間 30,308 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 25 MLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict

X = int(input())

half = X//2
half2 = X//2+X%2

A = []
cntC = [0]*301
for c in range(301):
    for b in range(c+1):
        for a in range(b+1):
            if a*a*a+b*b*b+c*c*c <= half:
                A.append(a*a*a+b*b*b+c*c*c)
                cntC[c] += 1
B = []
cntD = [0]*301
for d in range(301):
    for e in range(d, 301):
        for f in range(e, 301):
            if half2 <= d*d*d+e*e*e+f*f*f <= X:
                B.append(d*d*d+e*e*e+f*f*f)
                cntD[d] += 1

if len(A) >= len(B):
    D = defaultdict(int)
    idx = len(B)-1
    idxA = 300
    while 0 <= idxA and cntC[idxA] == 0: idxA -= 1
    idxB = 300
    while 0 <= idxB and cntD[idxB] == 0: idxB -= 1
    ans = 0
    for s in A[::-1]:
        while 0 <= idx and idxA <= idxB:
            D[B[idx]] += 1
            cntD[idxB] -= 1
            while 0 <= idxB and cntD[idxB] == 0: idxB -= 1
            idx -= 1
        ans += D[X-s]
        cntC[idxA] -= 1
        while 0 <= idxA and cntC[idxA] == 0: idxA -= 1
else:
    D = defaultdict(int)
    idx = len(A)-1
    idxA = 300
    while 0 <= idxA and cntC[idxA] == 0: idxA -= 1
    idxB = 300
    while 0 <= idxB and cntD[idxB] == 0: idxB -= 1
    ans = 0
    for s in B[::-1]:
        while 0 <= idx and idxA <= idxB:
            D[A[idx]] += 1
            cntC[idxA] -= 1
            while 0 <= idxA and cntC[idxA] == 0: idxA -= 1
            idx -= 1
        ans += D[X-s]
        cntD[idxB] -= 1
        while 0 <= idxB and cntD[idxB] == 0: idxB -= 1

print(ans)
0