葉林
Linked with GitHub
# 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'; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up