結果
問題 | No.2025 Select $k$-th Submultiset |
ユーザー | mkawa2 |
提出日時 | 2022-07-30 10:11:13 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,758 bytes |
コンパイル時間 | 111 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 61,500 KB |
最終ジャッジ日時 | 2024-07-20 05:54:56 |
合計ジャッジ時間 | 61,146 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 485 ms
43,728 KB |
testcase_01 | AC | 469 ms
43,692 KB |
testcase_02 | AC | 462 ms
44,084 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 | AC | 1,996 ms
57,900 KB |
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 | 457 ms
43,948 KB |
testcase_26 | AC | 471 ms
43,696 KB |
testcase_27 | AC | 471 ms
43,728 KB |
testcase_28 | AC | 465 ms
44,076 KB |
testcase_29 | AC | 456 ms
43,952 KB |
testcase_30 | AC | 462 ms
43,692 KB |
testcase_31 | AC | 468 ms
43,692 KB |
testcase_32 | AC | 463 ms
44,080 KB |
testcase_33 | AC | 460 ms
43,692 KB |
testcase_34 | AC | 457 ms
44,080 KB |
testcase_35 | AC | 478 ms
43,724 KB |
testcase_36 | AC | 464 ms
43,700 KB |
testcase_37 | AC | 458 ms
44,196 KB |
testcase_38 | AC | 461 ms
43,728 KB |
testcase_39 | AC | 458 ms
44,072 KB |
testcase_40 | AC | 472 ms
43,688 KB |
testcase_41 | AC | 466 ms
44,492 KB |
testcase_42 | AC | 460 ms
43,692 KB |
testcase_43 | AC | 466 ms
43,568 KB |
testcase_44 | AC | 472 ms
44,208 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") 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)