結果

問題 No.2093 Shio Ramen
ユーザー kyskys
提出日時 2022-10-07 21:26:08
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,072 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 76,336 KB
最終ジャッジ日時 2023-09-02 23:51:24
合計ジャッジ時間 4,227 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,272 KB
testcase_01 AC 69 ms
71,172 KB
testcase_02 AC 72 ms
71,588 KB
testcase_03 AC 70 ms
71,264 KB
testcase_04 AC 69 ms
71,296 KB
testcase_05 AC 68 ms
71,376 KB
testcase_06 AC 69 ms
71,484 KB
testcase_07 AC 70 ms
71,516 KB
testcase_08 AC 71 ms
71,344 KB
testcase_09 AC 77 ms
75,784 KB
testcase_10 AC 79 ms
75,908 KB
testcase_11 AC 74 ms
75,620 KB
testcase_12 AC 79 ms
75,856 KB
testcase_13 AC 77 ms
75,940 KB
testcase_14 AC 77 ms
76,200 KB
testcase_15 AC 81 ms
76,184 KB
testcase_16 AC 78 ms
76,336 KB
testcase_17 AC 81 ms
76,188 KB
testcase_18 AC 80 ms
76,208 KB
testcase_19 AC 80 ms
75,872 KB
testcase_20 AC 81 ms
76,160 KB
testcase_21 AC 81 ms
76,248 KB
testcase_22 AC 81 ms
75,972 KB
testcase_23 AC 80 ms
75,724 KB
testcase_24 AC 82 ms
76,208 KB
testcase_25 AC 80 ms
75,916 KB
testcase_26 AC 80 ms
76,120 KB
testcase_27 AC 81 ms
76,112 KB
testcase_28 AC 78 ms
76,188 KB
testcase_29 AC 79 ms
76,216 KB
testcase_30 AC 81 ms
76,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from sys import stdin, setrecursionlimit
    # setrecursionlimit(1000000)
    input = stdin.readline
    def iinput(): return int(input())
    def sinput(): return input().rstrip()
    def i0input(): return int(input()) - 1
    def linput(): return list(input().split())
    def liinput(): return list(map(int, input().split()))
    def miinput(): return map(int, input().split())
    def li0input(): return list(map(lambda x: int(x) - 1, input().split()))
    def mi0input(): return map(lambda x: int(x) - 1, input().split())
    INF = 1000000000000000000
    MOD = 1000000007

    # i番目の重みws[i], 価値vs[i]
    def solve(N, W, ws, vs):
        dp = [0] * (W+1)
        for i in range(N):
            # 価値v, 重さw
            v = vs[i]; w = ws[i]
            for j in range(W, w-1, -1):
                dp[j] = max(dp[j-w] + v, dp[j])
        return max(dp)

    N, W = miinput()
    vs = []
    ws = []

    for _ in [0] * N:
        w, v = miinput()
        vs.append(v)
        ws.append(w)
    
    print(solve(N, W, ws, vs))


main()
0