結果

問題 No.2025 Select $k$-th Submultiset
ユーザー mkawa2mkawa2
提出日時 2022-07-30 10:11:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,758 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 49,900 KB
最終ジャッジ日時 2023-09-27 11:48:46
合計ジャッジ時間 48,909 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
29,924 KB
testcase_01 AC 112 ms
29,984 KB
testcase_02 AC 122 ms
30,916 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 1,822 ms
47,940 KB
testcase_06 AC 1,759 ms
45,280 KB
testcase_07 AC 1,887 ms
46,332 KB
testcase_08 AC 1,783 ms
38,672 KB
testcase_09 AC 1,845 ms
46,852 KB
testcase_10 AC 1,808 ms
47,072 KB
testcase_11 AC 1,772 ms
39,296 KB
testcase_12 AC 1,823 ms
46,488 KB
testcase_13 AC 1,742 ms
37,676 KB
testcase_14 AC 1,782 ms
45,504 KB
testcase_15 AC 1,738 ms
46,928 KB
testcase_16 AC 1,757 ms
45,992 KB
testcase_17 AC 1,793 ms
46,964 KB
testcase_18 AC 1,758 ms
47,656 KB
testcase_19 AC 1,815 ms
46,112 KB
testcase_20 AC 1,798 ms
47,240 KB
testcase_21 AC 1,691 ms
38,372 KB
testcase_22 AC 1,817 ms
39,612 KB
testcase_23 AC 1,816 ms
47,288 KB
testcase_24 AC 1,853 ms
46,488 KB
testcase_25 AC 110 ms
29,884 KB
testcase_26 AC 111 ms
29,856 KB
testcase_27 AC 109 ms
29,928 KB
testcase_28 AC 111 ms
29,956 KB
testcase_29 AC 114 ms
29,996 KB
testcase_30 AC 111 ms
29,856 KB
testcase_31 AC 108 ms
29,900 KB
testcase_32 AC 108 ms
29,932 KB
testcase_33 AC 110 ms
29,888 KB
testcase_34 AC 111 ms
29,864 KB
testcase_35 AC 109 ms
29,944 KB
testcase_36 AC 112 ms
29,992 KB
testcase_37 AC 112 ms
29,984 KB
testcase_38 AC 114 ms
29,948 KB
testcase_39 AC 111 ms
29,976 KB
testcase_40 AC 117 ms
29,956 KB
testcase_41 AC 114 ms
29,916 KB
testcase_42 AC 110 ms
29,916 KB
testcase_43 AC 109 ms
29,956 KB
testcase_44 AC 109 ms
29,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
dij = [(-1, 1), (-1, 0), (-1, -1), (1, -1), (1, 1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

import numpy as np
from numpy.fft import rfft, irfft

def conv(aa, bb):
    m = len(aa)+len(bb)
    m = 1 << (m-1).bit_length()
    res = (irfft(rfft(aa, m)*rfft(bb, m))+0.5).astype("i8")
    r=np.searchsorted(res,lim,side="right")
    return res[:min(len(aa)+len(bb)-1,L+1,r)]

lim=10**18
n, L = LI()
cc = LI()
aa = []
for c in cc:
    arr = np.ones(c+1, dtype="i8")
    aa.append(arr)

for i in range(n-1)[::-1]:
    aa[i] = conv(aa[i], aa[i+1])
mx = aa[0][L]
# print(aa)

for i in range(n):
    cs = np.zeros(len(aa[i])+1, dtype="i8")
    cs[1:] = aa[i].cumsum()
    aa[i] = cs
# print(aa)

for _ in range(II()):
    k = II()
    if k > mx:
        print(-1)
        continue
    k -= 1
    ans = [0]*n
    s = 0
    for i in range(n-1):
        l = max(0, L-(s+cc[i]))
        r = np.searchsorted(aa[i+1], k+aa[i+1][l], side="right")-1
        ans[i] = L-s-r
        s += ans[i]
        k -= aa[i+1][r]-aa[i+1][l]
        # print(l, r, s, k)
    ans[-1] = L-s
    print(*ans)
0