結果

問題 No.1929 Exponential Sequence
ユーザー ShirotsumeShirotsume
提出日時 2022-05-06 22:20:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 86,388 KB
最終ジャッジ日時 2023-10-12 04:22:14
合計ジャッジ時間 5,190 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,392 KB
testcase_01 AC 96 ms
71,620 KB
testcase_02 AC 95 ms
71,216 KB
testcase_03 AC 236 ms
86,388 KB
testcase_04 AC 93 ms
71,372 KB
testcase_05 AC 94 ms
71,368 KB
testcase_06 AC 95 ms
71,600 KB
testcase_07 AC 95 ms
71,500 KB
testcase_08 AC 95 ms
71,356 KB
testcase_09 AC 96 ms
71,576 KB
testcase_10 AC 95 ms
71,304 KB
testcase_11 AC 95 ms
71,356 KB
testcase_12 AC 93 ms
71,640 KB
testcase_13 AC 93 ms
71,520 KB
testcase_14 AC 94 ms
71,540 KB
testcase_15 AC 111 ms
77,428 KB
testcase_16 AC 106 ms
77,444 KB
testcase_17 AC 95 ms
71,580 KB
testcase_18 AC 95 ms
71,464 KB
testcase_19 AC 94 ms
71,460 KB
testcase_20 AC 95 ms
71,384 KB
testcase_21 AC 240 ms
86,240 KB
testcase_22 AC 188 ms
82,676 KB
testcase_23 AC 238 ms
86,148 KB
testcase_24 AC 167 ms
80,488 KB
testcase_25 AC 242 ms
86,160 KB
testcase_26 AC 237 ms
86,244 KB
testcase_27 AC 96 ms
71,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#想定解じゃなさそう

import sys
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
INF = 2 ** 63 - 1
def solve(a, s):
    from collections import Counter
    n = len(a)
    dp = Counter()
    dp[0] = 1
    for i in range(n):
        e = Counter()
        for j in range(1, 40):
            now = a[i] ** j
            if now >= s:
                break
            for v, c in dp.items():
                e[v + now] += c
        dp = e
    return dp
n, s = mi()

a = li()
a.sort()



a1 = a[:n // 2]
a2 = a[n//2:]

dp1 = list(solve(a1, s).items())
dp2 = list(solve(a2, s).items())

dp1.sort()
dp2.sort()
summ = 0
for v, c in dp2:
    summ += c

now = len(dp2) - 1
ans = 0

for v, c in dp1:
    while now >= 0:
        if dp2[now][0] + v <= s:
            break
        summ -= dp2[now][1]
        now -= 1
    ans += c * summ
print(ans)
    


0