結果
問題 | No.2025 Select $k$-th Submultiset |
ユーザー | mkawa2 |
提出日時 | 2022-07-30 18:52:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 352 ms / 2,000 ms |
コード長 | 1,519 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 82,204 KB |
最終ジャッジ日時 | 2024-07-20 15:08:57 |
合計ジャッジ時間 | 13,065 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
52,804 KB |
testcase_01 | AC | 41 ms
52,780 KB |
testcase_02 | AC | 52 ms
64,516 KB |
testcase_03 | AC | 262 ms
81,896 KB |
testcase_04 | AC | 238 ms
82,204 KB |
testcase_05 | AC | 320 ms
81,360 KB |
testcase_06 | AC | 293 ms
80,880 KB |
testcase_07 | AC | 314 ms
81,436 KB |
testcase_08 | AC | 330 ms
81,368 KB |
testcase_09 | AC | 320 ms
81,196 KB |
testcase_10 | AC | 319 ms
81,576 KB |
testcase_11 | AC | 316 ms
81,252 KB |
testcase_12 | AC | 315 ms
81,748 KB |
testcase_13 | AC | 298 ms
81,832 KB |
testcase_14 | AC | 291 ms
81,516 KB |
testcase_15 | AC | 312 ms
82,040 KB |
testcase_16 | AC | 320 ms
81,364 KB |
testcase_17 | AC | 323 ms
81,860 KB |
testcase_18 | AC | 338 ms
81,184 KB |
testcase_19 | AC | 319 ms
81,472 KB |
testcase_20 | AC | 319 ms
81,440 KB |
testcase_21 | AC | 297 ms
80,824 KB |
testcase_22 | AC | 303 ms
80,736 KB |
testcase_23 | AC | 352 ms
81,756 KB |
testcase_24 | AC | 291 ms
81,376 KB |
testcase_25 | AC | 38 ms
53,876 KB |
testcase_26 | AC | 38 ms
53,444 KB |
testcase_27 | AC | 38 ms
53,016 KB |
testcase_28 | AC | 38 ms
52,996 KB |
testcase_29 | AC | 37 ms
52,900 KB |
testcase_30 | AC | 40 ms
52,824 KB |
testcase_31 | AC | 39 ms
52,824 KB |
testcase_32 | AC | 39 ms
54,480 KB |
testcase_33 | AC | 39 ms
53,816 KB |
testcase_34 | AC | 39 ms
54,172 KB |
testcase_35 | AC | 40 ms
53,144 KB |
testcase_36 | AC | 49 ms
62,284 KB |
testcase_37 | AC | 42 ms
54,256 KB |
testcase_38 | AC | 42 ms
54,452 KB |
testcase_39 | AC | 41 ms
53,424 KB |
testcase_40 | AC | 40 ms
52,996 KB |
testcase_41 | AC | 40 ms
52,536 KB |
testcase_42 | AC | 38 ms
52,948 KB |
testcase_43 | AC | 37 ms
53,188 KB |
testcase_44 | AC | 39 ms
53,772 KB |
ソースコード
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 from bisect import bisect_right lim = 10**18 n, L = LI() cc = LI() dp = [[0]*(L+2) for _ in range(n)] c = cc[-1] dp[-1][:c+2] = list(range(c+2)) dp[-1][c+2:] = [c+1]*(L-c) # p2D(dp) for i in range(n-1)[::-1]: c = cc[i] for j in range(L+1): l, r = max(0, j-c), j+1 dp[i][j+1] = dp[i][j]+dp[i+1][r]-dp[i+1][l] # p2D(dp) mx = dp[0][L+1]-dp[0][L] 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 = bisect_right(dp[i+1], k+dp[i+1][l])-1 ans[i] = L-s-r s += ans[i] k -= dp[i+1][r]-dp[i+1][l] # print(l, r, s, k) ans[-1] = L-s print(*ans)