HDU 1963 investor multiple backpacks

Source: Internet
Author: User

Question address: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1963

Find the maximum profit that can be obtained each time, multiple backpacks.

Here we will use a technique. The question "V [I]" is a multiple of 1000, so it can be divided by 1000.

The Code is as follows:

# Include <iostream> # include <cstdio> # include <cstdlib> # include <cmath> # include <cstring> # include <string> # include <vector> # include <list> # include <deque> # include <queue> # include <iterator> # include <stack> # include <map> # include <set> # include <algorithm> # include <cctype> using namespace STD; typedef long ll; const int n = 51510; const ll II = 1000000007; int DP [N], V [15], W [15]; int V, Y, N; int main () {int N, I, J, K, L, t; CIN> N; while (n --) {scanf ("% d ", & V, & Y, & T); for (I = 1; I <= T; I ++) {scanf ("% d ", & V [I], & W [I]); V [I]/= 1000 ;}for (L = 1; L <= y; l ++) {int temp = V/1000; memset (DP, 0, sizeof (DP); for (I = 1; I <= T; I ++) {for (j = V [I]; j <= temp; j ++) // multiple backpacks J = V [I]; j <= temp; j ++ // 01 backpack J = temp; j> = V [I]; J -- If (DP [J] <DP [J-V [I] + W [I]) DP [J] = DP [J-V [I] + W [I];} V + = DP [temp];} printf ("% d \ n ", v);} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.