結果

問題 No.1858 Gorgeous Knapsack
ユーザー lllllll88938494lllllll88938494
提出日時 2022-05-30 18:38:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 716 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 81,696 KB
実行使用メモリ 272,700 KB
最終ジャッジ日時 2023-10-21 00:22:56
合計ジャッジ時間 11,303 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,472 KB
testcase_01 AC 36 ms
53,472 KB
testcase_02 AC 35 ms
53,472 KB
testcase_03 AC 45 ms
61,776 KB
testcase_04 AC 272 ms
105,252 KB
testcase_05 AC 93 ms
82,868 KB
testcase_06 AC 300 ms
122,600 KB
testcase_07 AC 188 ms
102,224 KB
testcase_08 AC 383 ms
142,972 KB
testcase_09 AC 606 ms
190,836 KB
testcase_10 AC 220 ms
98,908 KB
testcase_11 AC 328 ms
121,940 KB
testcase_12 AC 510 ms
165,616 KB
testcase_13 AC 112 ms
76,768 KB
testcase_14 AC 46 ms
61,876 KB
testcase_15 AC 46 ms
62,076 KB
testcase_16 AC 48 ms
61,896 KB
testcase_17 AC 37 ms
53,472 KB
testcase_18 AC 39 ms
53,472 KB
testcase_19 AC 39 ms
53,472 KB
testcase_20 AC 36 ms
53,472 KB
testcase_21 AC 37 ms
53,472 KB
testcase_22 AC 36 ms
53,472 KB
testcase_23 AC 36 ms
53,472 KB
testcase_24 AC 118 ms
89,144 KB
testcase_25 AC 388 ms
145,336 KB
testcase_26 AC 369 ms
142,288 KB
testcase_27 AC 341 ms
126,320 KB
testcase_28 AC 233 ms
119,656 KB
testcase_29 AC 79 ms
76,656 KB
testcase_30 AC 87 ms
77,080 KB
testcase_31 AC 85 ms
77,024 KB
testcase_32 AC 79 ms
76,672 KB
testcase_33 AC 84 ms
76,936 KB
testcase_34 AC 703 ms
272,696 KB
testcase_35 AC 348 ms
272,520 KB
testcase_36 AC 716 ms
272,700 KB
testcase_37 AC 38 ms
53,472 KB
testcase_38 AC 74 ms
76,944 KB
testcase_39 AC 39 ms
59,460 KB
testcase_40 AC 353 ms
272,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
jue=[list(map(int,input().split())) for i in range(n)]
jue.sort(reverse=True)

dp=[[-1]*(m+1) for i in range(n+1)]
dp[0][0]=0
ans=0

for i in range(n):
    for j in range(m):
        if dp[i][j] == -1:
            continue
        if j+jue[i][1] <= m:
            dp[i+1][j+jue[i][1]] = max(dp[i][j]+jue[i][0],dp[i+1][j+jue[i][1]])
            ans = max(ans,(dp[i][j]+jue[i][0]) * jue[i][0])
        dp[i+1][j] = max(dp[i][j],dp[i+1][j])
        
print(ans)
0