結果

問題 No.1872 Dictionary Order
ユーザー mkawa2mkawa2
提出日時 2022-03-12 12:06:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 1,273 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 209,428 KB
最終ジャッジ日時 2023-10-19 12:39:15
合計ジャッジ時間 5,062 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 214 ms
134,100 KB
testcase_01 AC 46 ms
59,396 KB
testcase_02 AC 89 ms
82,808 KB
testcase_03 AC 54 ms
70,380 KB
testcase_04 AC 126 ms
100,916 KB
testcase_05 AC 48 ms
61,444 KB
testcase_06 AC 75 ms
77,668 KB
testcase_07 AC 66 ms
77,324 KB
testcase_08 AC 46 ms
59,784 KB
testcase_09 AC 57 ms
72,296 KB
testcase_10 AC 69 ms
77,520 KB
testcase_11 AC 87 ms
82,472 KB
testcase_12 AC 56 ms
73,348 KB
testcase_13 AC 56 ms
70,248 KB
testcase_14 AC 84 ms
82,320 KB
testcase_15 AC 100 ms
90,108 KB
testcase_16 AC 51 ms
64,228 KB
testcase_17 AC 70 ms
77,308 KB
testcase_18 AC 74 ms
77,692 KB
testcase_19 AC 70 ms
77,544 KB
testcase_20 AC 63 ms
77,388 KB
testcase_21 AC 82 ms
82,104 KB
testcase_22 AC 301 ms
187,420 KB
testcase_23 AC 105 ms
83,152 KB
testcase_24 AC 82 ms
77,860 KB
testcase_25 AC 155 ms
102,168 KB
testcase_26 AC 83 ms
77,868 KB
testcase_27 AC 149 ms
102,260 KB
testcase_28 AC 245 ms
150,740 KB
testcase_29 AC 278 ms
172,160 KB
testcase_30 AC 49 ms
61,656 KB
testcase_31 AC 332 ms
209,428 KB
testcase_32 AC 40 ms
53,372 KB
testcase_33 AC 40 ms
53,372 KB
testcase_34 AC 47 ms
59,940 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)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

n, m = LI()
aa = LI()[::-1]
pp = LI()[::-1]
ptoi = {p: i for i, p in enumerate(pp)}

dp = [[] for _ in range(m+1)]
dp[0] = [-1]

for a, p in zip(aa, pp):
    for s in range(m-a, -1, -1):
        if dp[s] == []: continue
        dp[s+a].append(p)

if dp[m] == []:
    print(-1)
else:
    ans = []
    mx = n+5
    s = m
    while s:
        for p in sorted(dp[s]):
            i = ptoi[p]
            if i >= mx: continue
            mx = i
            ans.append(n-ptoi[p])
            s -= aa[i]
            break
    print(len(ans))
    print(*ans)
0