結果

問題 No.1929 Exponential Sequence
ユーザー 👑 tamatotamato
提出日時 2022-05-06 22:48:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 1,185 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 84,696 KB
最終ジャッジ日時 2023-10-12 04:22:46
合計ジャッジ時間 4,172 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,104 KB
testcase_01 AC 73 ms
71,400 KB
testcase_02 AC 76 ms
71,148 KB
testcase_03 AC 180 ms
84,696 KB
testcase_04 AC 73 ms
71,312 KB
testcase_05 AC 73 ms
71,204 KB
testcase_06 AC 72 ms
71,020 KB
testcase_07 AC 74 ms
71,236 KB
testcase_08 AC 73 ms
71,240 KB
testcase_09 AC 74 ms
71,112 KB
testcase_10 AC 75 ms
70,932 KB
testcase_11 AC 74 ms
71,240 KB
testcase_12 AC 73 ms
70,932 KB
testcase_13 AC 75 ms
71,172 KB
testcase_14 AC 74 ms
71,360 KB
testcase_15 AC 92 ms
76,604 KB
testcase_16 AC 97 ms
76,232 KB
testcase_17 AC 73 ms
71,232 KB
testcase_18 AC 72 ms
70,928 KB
testcase_19 AC 72 ms
71,360 KB
testcase_20 AC 76 ms
71,112 KB
testcase_21 AC 181 ms
84,376 KB
testcase_22 AC 145 ms
82,148 KB
testcase_23 AC 178 ms
84,416 KB
testcase_24 AC 132 ms
79,308 KB
testcase_25 AC 178 ms
84,336 KB
testcase_26 AC 180 ms
84,436 KB
testcase_27 AC 73 ms
71,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    N, S = map(int, input().split())
    A_ori = list(map(int, input().split()))

    A_split = [A_ori[:4], A_ori[4:]]

    res_list = []
    for A in A_split:
        dp = {0: 1}
        for a in A:
            ax = 1
            dp_new = {}
            for x in range(31):
                ax *= a
                if ax > S:
                    break
                for y in dp:
                    y_new = y + ax
                    if y_new > S:
                        continue
                    if y_new not in dp_new:
                        dp_new[y_new] = 0
                    dp_new[y_new] += dp[y]
            dp = dp_new

        res = []
        for y in dp:
            res.append((y, dp[y]))
        res.sort(key=lambda z: z[0])
        res_list.append(res)

    res0, res1 = res_list
    val = []
    cnt_cs = [0]
    for y, c in res1:
        val.append(y)
        cnt_cs.append(cnt_cs[-1] + c)
    ans = 0
    for y, c in res0:
        j = bisect_left(val, S - y + 1)
        ans += cnt_cs[j] * c
    print(ans)


if __name__ == '__main__':
    main()
0