提出 #31741688


ソースコード 拡げる

#another
#atcoder template
def main():
    import sys
    input = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #another version
    n, W = map(int, input().split())

    import numpy as np
    dp = np.zeros((n+1, W+1), np.int64)

    for i in range(n):
        w, v = map(int, input().split())
        np.maximum(dp[i, w:], dp[i, :-w]+v, out = dp[i+1, w:])
        dp[i+1, :w] = dp[i, :w]
    print(dp[-1, -1])
    
    #N = 1のときなどcorner caseを確認!
if __name__ == "__main__":
    main()

提出情報

提出日時
問題 D - Knapsack 1
ユーザ denovo2021
言語 Python (3.8.2)
得点 100
コード長 581 Byte
結果 AC
実行時間 162 ms
メモリ 105376 KiB

ジャッジ結果

セット名 All
得点 / 配点 100 / 100
結果
AC × 13
セット名 テストケース
All 0_00, 0_01, 0_02, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09
ケース名 結果 実行時間 メモリ
0_00 AC 107 ms 27176 KiB
0_01 AC 106 ms 27076 KiB
0_02 AC 104 ms 27156 KiB
1_00 AC 104 ms 27348 KiB
1_01 AC 160 ms 105364 KiB
1_02 AC 153 ms 102712 KiB
1_03 AC 162 ms 104332 KiB
1_04 AC 157 ms 104336 KiB
1_05 AC 160 ms 104352 KiB
1_06 AC 156 ms 105084 KiB
1_07 AC 160 ms 104372 KiB
1_08 AC 162 ms 103944 KiB
1_09 AC 158 ms 105376 KiB