結果

問題 No.2093 Shio Ramen
ユーザー ygd.ygd.
提出日時 2022-10-07 21:58:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 1,147 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 9,128 KB
最終ジャッジ日時 2023-09-03 01:46:51
合計ジャッジ時間 6,338 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
8,860 KB
testcase_01 AC 24 ms
8,940 KB
testcase_02 AC 23 ms
8,980 KB
testcase_03 AC 24 ms
8,908 KB
testcase_04 AC 24 ms
8,900 KB
testcase_05 AC 24 ms
8,936 KB
testcase_06 AC 25 ms
8,908 KB
testcase_07 AC 23 ms
8,948 KB
testcase_08 AC 23 ms
9,084 KB
testcase_09 AC 99 ms
9,052 KB
testcase_10 AC 193 ms
8,928 KB
testcase_11 AC 35 ms
9,032 KB
testcase_12 AC 208 ms
8,976 KB
testcase_13 AC 234 ms
9,076 KB
testcase_14 AC 252 ms
9,012 KB
testcase_15 AC 194 ms
8,976 KB
testcase_16 AC 75 ms
8,976 KB
testcase_17 AC 315 ms
8,968 KB
testcase_18 AC 214 ms
9,096 KB
testcase_19 AC 263 ms
9,044 KB
testcase_20 AC 290 ms
9,076 KB
testcase_21 AC 278 ms
8,984 KB
testcase_22 AC 280 ms
9,008 KB
testcase_23 AC 192 ms
8,928 KB
testcase_24 AC 195 ms
8,936 KB
testcase_25 AC 201 ms
9,076 KB
testcase_26 AC 196 ms
8,976 KB
testcase_27 AC 194 ms
9,128 KB
testcase_28 AC 195 ms
9,120 KB
testcase_29 AC 203 ms
8,936 KB
testcase_30 AC 194 ms
9,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
import math
import bisect
#import itertools
#import random
from heapq import heapify, heappop, heappush
from collections import defaultdict 
#from collections import deque
import copy #DeepCopy: hoge = [_[:] for _ in hogehoge]
#from functools import lru_cache
#@lru_cache(maxsize=None)
MOD = pow(10,9) + 7
#MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    N,I = map(int,input().split()); INF = 1 << 30
    S = [] ; A= []
    for i in range(N):
        s,a = map(int,input().split())
        S.append(s)
        A.append(a)

    # dp[i][j]:i番目の塩ラーメンまで見て塩の濃さがjの時の味の濃さの最大値
    M = 1005
    dp = [-INF]*M
    dp[0] = 0

    for s,a in zip(S,A):
        p = copy.copy(dp)
        dp,p = p,dp
        for j in range(M):
            if j+s < M:
                dp[j+s] = max(dp[j+s], p[j] + a)
        # print(dp[:20])

    ans = max(dp[:I+1])
    print(ans)


if __name__ == '__main__':
    main()
0