結果

問題 No.2093 Shio Ramen
ユーザー MagentorMagentor
提出日時 2022-10-07 21:53:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 567 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 197,324 KB
実行使用メモリ 11,636 KB
最終ジャッジ日時 2023-09-03 01:37:13
合計ジャッジ時間 6,827 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,496 KB
testcase_01 AC 4 ms
11,516 KB
testcase_02 AC 5 ms
11,504 KB
testcase_03 AC 5 ms
11,540 KB
testcase_04 AC 4 ms
11,576 KB
testcase_05 AC 4 ms
11,564 KB
testcase_06 AC 5 ms
11,548 KB
testcase_07 AC 5 ms
11,516 KB
testcase_08 AC 5 ms
11,552 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 5 ms
11,636 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
long long wt[105], val[105];
long long dp[105][10005];

long long func(int index, int wt_left) {
	if(wt_left==0) return 0;
	if(index<0) return 0;
	if(dp[index][wt_left]!=-1) return dp[index][wt_left];
	long long ans = func(index-1, wt_left);
	if(wt_left-wt[index]>=0)
	ans = max(ans, func(index-1, wt_left-wt[index]) + val[index]);
	return dp[index][wt_left] = ans;
}

int main() {
	memset(dp,-1,sizeof(dp));
	long long n,w;
	cin >> n >> w;
	for(int i=0; i<n; i++) {
		cin >> wt[i] >> val[i];
	}
	cout << func(n-1, w);
}

0