結果

問題 No.1929 Exponential Sequence
ユーザー Akijin_007Akijin_007
提出日時 2022-05-06 22:17:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 1,351 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 85,796 KB
最終ジャッジ日時 2023-10-12 04:21:58
合計ジャッジ時間 4,530 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,332 KB
testcase_01 AC 75 ms
71,208 KB
testcase_02 AC 74 ms
70,820 KB
testcase_03 AC 181 ms
85,624 KB
testcase_04 AC 73 ms
70,936 KB
testcase_05 AC 74 ms
71,212 KB
testcase_06 AC 71 ms
71,236 KB
testcase_07 AC 71 ms
71,080 KB
testcase_08 AC 73 ms
71,232 KB
testcase_09 AC 74 ms
71,396 KB
testcase_10 AC 76 ms
71,084 KB
testcase_11 AC 79 ms
71,108 KB
testcase_12 AC 77 ms
71,172 KB
testcase_13 AC 79 ms
71,020 KB
testcase_14 AC 78 ms
71,072 KB
testcase_15 AC 97 ms
76,496 KB
testcase_16 AC 85 ms
75,120 KB
testcase_17 AC 80 ms
71,152 KB
testcase_18 AC 79 ms
71,260 KB
testcase_19 AC 77 ms
71,196 KB
testcase_20 AC 79 ms
71,116 KB
testcase_21 AC 188 ms
85,596 KB
testcase_22 AC 152 ms
82,872 KB
testcase_23 AC 187 ms
85,796 KB
testcase_24 AC 138 ms
80,292 KB
testcase_25 AC 187 ms
85,724 KB
testcase_26 AC 186 ms
85,540 KB
testcase_27 AC 77 ms
71,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

n, S = map(int, input().split())
A = list(map(int, input().split()))

B = A[n//2:]
A = A[:n//2]

d = dict()
d[0] = 1

for i in range(len(A)):
    t = 1
    a = A[i]
    nd = dict()
    while True:
        t *= a
        if t > S:
            break
        for x, v in d.items():
            if x + t > S:
                continue
            elif x + t not in nd:
                nd[x+t] = v
            else:
                nd[x+t] += v
    d = dict(nd)

da = dict(d)

d = dict()
d[0] = 1

for i in range(len(B)):
    t = 1
    a = B[i]
    nd = dict()
    while True:
        t *= a
        if t > S:
            break
        for x, v in d.items():
            if x + t > S:
                continue
            elif x + t not in nd:
                nd[x+t] = v
            else:
                nd[x+t] += v
    d = dict(nd)

b = list(d.items())
b = sorted(b)

s = [0] * (len(b) + 1)
lb = []
for i in range(len(b)):
    s[i+1] = s[i] + b[i][1]
    lb.append(b[i][0])

# print(da)
# print(d)

import bisect

ans = 0
# print(lb)

for x, v in da.items():
    t = bisect.bisect_right(lb, S-x)
    # print(t, S-x)
    ans += s[t] * v

print(ans)
0