Transport equipment (Codevs 1669)

Source: Internet
Author: User

1669 Transport Equipment

time limit: 1 sspace limit: 256000 KBtitle level: Diamonds Diamond SolvingTitle Description Description

After Germany relaxed its offensive against Britain, it pointed its finger at the northeast-the Soviet Union. In early 1943, the East line of the station head to the white-hot stage. According to reliable intelligence, more than 900,000 German troops in Kursk are ready to launch a great offensive. Therefore, Marshal Zhukov requires you to immediately transport large quantities of equipment from the Far East military plant to support the Kursk front. The train driver tells you that a train can hold up to a V-volume of weaponry, but you may not be able to fill it up because the train can carry a maximum of G units of weight. At the same time, the Military factory warehouse provides you with a list of equipment detailing the volume, weight and firepower of each piece of equipment. In order to effectively support Marshal Zhukov, you need to find a solution that maximizes the total firepower value.

Enter a description Input Description

The first line: V and G represent the maximum weight and volume. The second line: n means that the warehouse has n pieces of equipment; third to N+2 line: 3 number per line Ti Vi GI indicates the firepower value, volume and weight of the equipment;

Output description Output Description

Outputs a number that represents the maximum firepower value that may be obtained

Sample input Sample Input

6 5

4

10 2 2

20 3 2

40 4 3

30 3 3

Sample output Sample Output

50

Data range and Tips Data Size & Hint

"Data Range"

For 50% of data, v,g,n≤100

For 100% of data, v,g,n≤1000

#include <cstdio>#include<iostream>#include<cmath>#defineM 1010using namespacestd;intW[m],v[m],huo[m],f[m][m];intHeavy,tiji,n;intMain () {scanf ("%d%d%d",&tiji,&heavy,&N);  for(intI=1; i<=n;i++) scanf ("%d%d%d",&huo[i],&v[i],&W[i]);  for(intI=1; i<=n;i++)       for(intj=heavy;j>=w[i];j--)         for(intk=tiji;k>=v[i];k--) F[j][k]=max (f[j][k],f[j-w[i]][k-v[i]]+Huo[i]); printf ("%d", F[heavy][tiji]); return 0;}
View Code

Transport equipment (Codevs 1669)

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.