# ZeroJudge - d637: 路過的鴨duck ### 題目連結:https://zerojudge.tw/ShowProblem?problemid=d637 ###### tags: `ZeroJudge` `動態規劃(Dynamic Programming)` ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { cin.sync_with_stdio(false); cin.tie(nullptr); int DP[101] = {}, feeds, volume, fullness, maximum = 0; cin >> feeds; while (feeds--) { cin >> volume >> fullness; for (int i = 100; i >= volume; --i) DP[i] = max(DP[i], DP[i - volume] + fullness); } for (int i = 0; i <= 100; ++i) maximum = max(maximum, DP[i]); cout << maximum << '\n'; } ```