結果
問題 | No.2025 Select $k$-th Submultiset |
ユーザー | mkawa2 |
提出日時 | 2022-07-30 10:08:38 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,701 bytes |
コンパイル時間 | 186 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 59,788 KB |
最終ジャッジ日時 | 2024-07-20 05:50:52 |
合計ジャッジ時間 | 9,150 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 527 ms
43,632 KB |
testcase_01 | AC | 536 ms
43,876 KB |
testcase_02 | AC | 537 ms
43,620 KB |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | AC | 523 ms
43,864 KB |
testcase_26 | AC | 530 ms
43,876 KB |
testcase_27 | AC | 534 ms
43,892 KB |
testcase_28 | AC | 525 ms
44,008 KB |
testcase_29 | AC | 527 ms
44,004 KB |
testcase_30 | AC | 525 ms
43,876 KB |
testcase_31 | AC | 521 ms
43,868 KB |
testcase_32 | AC | 517 ms
43,508 KB |
testcase_33 | AC | 525 ms
43,736 KB |
testcase_34 | AC | 535 ms
43,864 KB |
testcase_35 | AC | 530 ms
43,764 KB |
testcase_36 | AC | 535 ms
43,864 KB |
testcase_37 | AC | 525 ms
43,868 KB |
testcase_38 | AC | 529 ms
43,892 KB |
testcase_39 | AC | 527 ms
43,616 KB |
testcase_40 | AC | 531 ms
43,872 KB |
testcase_41 | AC | 532 ms
44,004 KB |
testcase_42 | AC | 532 ms
43,616 KB |
testcase_43 | AC | 534 ms
43,880 KB |
testcase_44 | AC | 535 ms
43,740 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 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") return res[:min(len(aa)+len(bb)-1,L+1)] 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)