結果

問題 No.1929 Exponential Sequence
コンテスト
ユーザー ああ
提出日時 2026-05-28 00:23:51
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 700 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 361 ms
コンパイル使用メモリ 84,960 KB
実行使用メモリ 187,436 KB
最終ジャッジ日時 2026-05-28 00:23:56
合計ジャッジ時間 3,386 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def aa(x):
    global s
    res=[];p=1
    for i in x:
        c=[]
        d=i
        while s>=d:
            c.append(d);d*=i
        d=[]
        if p:
        	res=c;p=0
        	continue
        for j in res:
            for l in c:
                if j+l>s:
                    continue
                d.append(j+l)
        res=d
    return res

n,s=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)>s:
    print(0)
    exit()
if len(a)==1:
	print(len(aa(a)));exit()
b=aa(a[:n//2]);c=aa(a[n//2:])
b.sort()
b=[0]+b;ans=0
for i in c:
    q,w=0,len(b)
    while w-q>1:
        m=(q+w)//2
        if b[m]+i<=s:
            q=m
        else:
            w=m
    ans+=q
print(ans)
0