結果
問題 | No.2093 Shio Ramen |
ユーザー |
![]() |
提出日時 | 2022-10-07 21:53:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 567 bytes |
コンパイル時間 | 1,986 ms |
コンパイル使用メモリ | 191,616 KB |
最終ジャッジ日時 | 2025-02-07 23:18:01 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 RE * 21 |
ソースコード
#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); }