結果

問題 No.1929 Exponential Sequence
ユーザー 👑 rin204rin204
提出日時 2022-05-06 21:51:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 282 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 197,388 KB
最終ジャッジ日時 2023-10-12 04:20:42
合計ジャッジ時間 4,684 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,060 KB
testcase_01 AC 69 ms
71,344 KB
testcase_02 AC 69 ms
71,128 KB
testcase_03 AC 282 ms
197,216 KB
testcase_04 AC 68 ms
70,908 KB
testcase_05 AC 67 ms
71,264 KB
testcase_06 AC 67 ms
71,340 KB
testcase_07 AC 69 ms
71,256 KB
testcase_08 AC 69 ms
71,200 KB
testcase_09 AC 68 ms
71,104 KB
testcase_10 AC 68 ms
70,880 KB
testcase_11 AC 67 ms
71,256 KB
testcase_12 AC 67 ms
71,260 KB
testcase_13 AC 68 ms
71,268 KB
testcase_14 AC 68 ms
71,244 KB
testcase_15 AC 76 ms
75,772 KB
testcase_16 AC 69 ms
71,208 KB
testcase_17 AC 68 ms
71,272 KB
testcase_18 AC 67 ms
71,200 KB
testcase_19 AC 67 ms
71,064 KB
testcase_20 AC 68 ms
70,912 KB
testcase_21 AC 274 ms
196,740 KB
testcase_22 AC 214 ms
151,028 KB
testcase_23 AC 273 ms
196,412 KB
testcase_24 AC 170 ms
126,764 KB
testcase_25 AC 269 ms
185,636 KB
testcase_26 AC 279 ms
197,388 KB
testcase_27 AC 68 ms
71,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if n == 1:
    a = A[0]
    x = a
    ans = 0
    while x <= S:
        ans += 1
        x *= a
    print(ans)
    exit()
L = A[:n//2]
R = A[n//2:]

left = [0]
for a in L:
    tmp = []
    x = a
    while x < S:
        tmp.append(x)
        x *= a
    nl = []
    for t in tmp:
        for l in left:
            if t + l <= S:
                nl.append(t + l)
    left = nl
left.sort()

right = [0]
for a in R:
    tmp = []
    x = a
    while x < S:
        tmp.append(x)
        x *= a
    nr = []
    for t in tmp:
        for l in right:
            if t + l <= S:
                nr.append(t + l)
    right = nr
right.sort()

ans = 0
p = 0
left.append(S + 1)
for r in right[::-1]:
    while r + left[p] <= S:
        p += 1
    ans += p
print(ans)
0