結果

問題 No.2025 Select $k$-th Submultiset
ユーザー hahhohahho
提出日時 2022-07-09 16:09:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 660 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 851 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 86,724 KB
最終ジャッジ日時 2023-09-20 03:31:29
合計ジャッジ時間 18,694 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,288 KB
testcase_01 AC 74 ms
71,336 KB
testcase_02 AC 88 ms
76,296 KB
testcase_03 AC 514 ms
86,444 KB
testcase_04 AC 476 ms
86,724 KB
testcase_05 AC 580 ms
84,356 KB
testcase_06 AC 555 ms
83,092 KB
testcase_07 AC 557 ms
85,632 KB
testcase_08 AC 552 ms
84,400 KB
testcase_09 AC 602 ms
85,144 KB
testcase_10 AC 575 ms
85,108 KB
testcase_11 AC 566 ms
84,088 KB
testcase_12 AC 660 ms
85,432 KB
testcase_13 AC 539 ms
84,864 KB
testcase_14 AC 589 ms
85,024 KB
testcase_15 AC 562 ms
85,008 KB
testcase_16 AC 594 ms
84,976 KB
testcase_17 AC 549 ms
85,008 KB
testcase_18 AC 603 ms
83,724 KB
testcase_19 AC 570 ms
83,668 KB
testcase_20 AC 580 ms
83,704 KB
testcase_21 AC 595 ms
84,232 KB
testcase_22 AC 556 ms
83,904 KB
testcase_23 AC 612 ms
85,076 KB
testcase_24 AC 591 ms
84,104 KB
testcase_25 AC 74 ms
71,608 KB
testcase_26 AC 75 ms
71,240 KB
testcase_27 AC 78 ms
71,424 KB
testcase_28 AC 74 ms
71,084 KB
testcase_29 AC 74 ms
71,284 KB
testcase_30 AC 74 ms
71,352 KB
testcase_31 AC 76 ms
71,420 KB
testcase_32 AC 77 ms
71,584 KB
testcase_33 AC 74 ms
71,340 KB
testcase_34 AC 76 ms
71,268 KB
testcase_35 AC 74 ms
71,240 KB
testcase_36 AC 91 ms
75,848 KB
testcase_37 AC 76 ms
71,400 KB
testcase_38 AC 76 ms
71,324 KB
testcase_39 AC 76 ms
71,444 KB
testcase_40 AC 76 ms
71,280 KB
testcase_41 AC 74 ms
71,624 KB
testcase_42 AC 75 ms
71,452 KB
testcase_43 AC 75 ms
71,620 KB
testcase_44 AC 73 ms
71,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect

n, l = map(int, input().split())
c = list(map(int, input().split()))

# dp[i][j] := c[i:]を使って長さj未満の部分列を作る場合の通り数
dp = [[0] + [1] * (l + 1) for _ in range(n + 1)]

for i in reversed(range(n)):
    for j in range(1, l + 2):
        dp[i][j] = dp[i + 1][j] - dp[i + 1][max(j - c[i] - 1, 0)] + dp[i][j - 1]

m = int(input())

for _ in range(m):
    k = int(input()) - 1
    if k >= dp[0][-1] - dp[0][-2]:
        print(-1)
        continue
    res = [0] * n
    remaining = l + 1
    for i in range(n):
        offset = dp[i + 1][max(remaining - c[i] - 1, 0)]
        j = bisect(dp[i + 1], k + offset)
        k -= dp[i + 1][j - 1] - offset
        res[i] = remaining - j
        remaining = j
    print(*res)
0