結果

問題 No.2730 Two Types Luggage
ユーザー kusirakusirakusirakusira
提出日時 2024-03-14 14:04:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 592 ms / 2,000 ms
コード長 885 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 265,800 KB
最終ジャッジ日時 2024-03-14 14:04:44
合計ジャッジ時間 11,591 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 46 ms
62,236 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 AC 391 ms
75,288 KB
testcase_05 AC 97 ms
72,212 KB
testcase_06 AC 97 ms
72,212 KB
testcase_07 AC 159 ms
75,156 KB
testcase_08 AC 390 ms
75,288 KB
testcase_09 AC 36 ms
53,460 KB
testcase_10 AC 519 ms
259,792 KB
testcase_11 AC 497 ms
263,928 KB
testcase_12 AC 102 ms
102,548 KB
testcase_13 AC 249 ms
181,832 KB
testcase_14 AC 592 ms
265,800 KB
testcase_15 AC 221 ms
163,604 KB
testcase_16 AC 147 ms
116,344 KB
testcase_17 AC 117 ms
94,984 KB
testcase_18 AC 121 ms
112,348 KB
testcase_19 AC 174 ms
136,168 KB
testcase_20 AC 141 ms
113,816 KB
testcase_21 AC 123 ms
107,840 KB
testcase_22 AC 472 ms
107,220 KB
testcase_23 AC 155 ms
75,692 KB
testcase_24 AC 468 ms
256,408 KB
testcase_25 AC 327 ms
185,148 KB
testcase_26 AC 82 ms
91,648 KB
testcase_27 AC 273 ms
198,128 KB
testcase_28 AC 130 ms
107,068 KB
testcase_29 AC 425 ms
233,072 KB
testcase_30 AC 439 ms
257,792 KB
testcase_31 AC 215 ms
156,684 KB
testcase_32 AC 356 ms
240,856 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()))

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

# 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