結果

問題 No.2730 Two Types Luggage
ユーザー kusirakusirakusirakusira
提出日時 2024-04-04 18:14:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 573 ms / 2,000 ms
コード長 1,138 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 267,152 KB
最終ジャッジ日時 2024-04-04 18:14:44
合計ジャッジ時間 12,030 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 46 ms
62,224 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 AC 385 ms
75,284 KB
testcase_05 AC 96 ms
72,336 KB
testcase_06 AC 94 ms
72,336 KB
testcase_07 AC 154 ms
75,280 KB
testcase_08 AC 413 ms
75,284 KB
testcase_09 AC 36 ms
53,460 KB
testcase_10 AC 437 ms
259,932 KB
testcase_11 AC 455 ms
265,680 KB
testcase_12 AC 100 ms
102,804 KB
testcase_13 AC 256 ms
182,296 KB
testcase_14 AC 573 ms
267,152 KB
testcase_15 AC 217 ms
163,624 KB
testcase_16 AC 147 ms
116,596 KB
testcase_17 AC 117 ms
94,996 KB
testcase_18 AC 126 ms
112,336 KB
testcase_19 AC 171 ms
136,316 KB
testcase_20 AC 140 ms
114,156 KB
testcase_21 AC 114 ms
108,008 KB
testcase_22 AC 449 ms
107,220 KB
testcase_23 AC 164 ms
75,832 KB
testcase_24 AC 472 ms
256,536 KB
testcase_25 AC 297 ms
185,148 KB
testcase_26 AC 81 ms
91,892 KB
testcase_27 AC 268 ms
198,272 KB
testcase_28 AC 129 ms
107,068 KB
testcase_29 AC 431 ms
232,840 KB
testcase_30 AC 445 ms
257,936 KB
testcase_31 AC 210 ms
157,736 KB
testcase_32 AC 345 ms
244,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 入力
n,m,w = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

if((1<=n<=10**6)==False): print(-1)
if((1<=m<=20)==False): print(-1)
if((1<=n<=10**9)==False): print(-1)
# step2で行う処理のために前計算(Aを降順に並び替え累積和を取る。)
A.sort(reverse = True)
CA = [0]
for i in range(n):
    if((1<=A[i]<=10**9)==False): print(-1)
    CA.append(CA[-1] + A[i])

for i in range(m):
    if((1<=B[i]<=10**9)==False): print(-1)
    if((1<=C[i]<=10**9)==False): print(-1)
# step1. タイプBの荷物の選び方を全探索する。(bit全探索) 
ans = 0
for i in range(1<<m):
    # 選んだ荷物の総重量cと総価値v
    c = 0
    v = 0
    for j in range(m):
        # 選ぶ
        if(i >> j & 1):
            c += B[j]
            v += C[j]

    # タイプBのだけで総重量を超えたらパスする
    if(c > w): continue
    # step2. ナップザックの残りの容量でタイプAの荷物を詰めれるだけ詰める
    v += CA[min(w-c,  n)]
    # 答えの更新
    ans = max(ans,v)

# 出力
print(ans)
0