Hdoj topic 2670 Girl Love Value (01 backpack)

Source: Internet
Author: User

Girl Love ValueTime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 748 Accepted Submission (s): 417


Problem Descriptionlove in college are a happy thing but always has so many pity boys or girls can not find it.
Now a chance are coming for lots of single boys. The most beautiful and lovely and intelligent girl in hdu,named Kiki want to choose K Single boys to travel Jolmo Lungma. You may ask one girls and K boys are not a interesting thing to K boys. But know Kiki has a lot of friends which all is beautiful girl!!!!. Now you must being sure how wonderful things it was if you are choose by Kiki.



Problem is coming, n a boys want to go to travel with Kiki. But Kiki only choose K from them. Kiki every day would choose one single boy, so after K days the choosing would be end. Each boys has a love value (Li) to Kiki, and also has a other value (Bi), if one boy can is choose by Kiki he love Value would decrease Bi every day.
Kiki must choose K Boys, so she want the total love value maximum.

Inputthe input contains multiple test cases.
First line give the integer n,k (1<=k<=n<=1000)
Second line give n integer li (li <= 100000).
Last line give n integer Bi. (bi<=1000)

Outputoutput only one integer is about the maximum total love value Kiki can get by choose K Boys.
Sample Input
3 310 20 304 5 64 320 30 40 502 7 6 5

Sample Output
47104

Authoryifenfei
Sourcehdu Girls ' open--who says women are inferior to men
Recommendlcy | We have carefully selected several similar problems for you:2668 2675 2671 2673 2672


The main topic: There are N boys, every boy has a love value Li for that girl, a diminishing value bi, when the girl does not choose him when his love minus did not choose his days multiplied by the decreasing value, only one boy per day, asked to choose M to get the maximum m value is how much

AC Code

#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX (b) (a>b?a:b) struct s{int Li,bi;} A[1010];int dp[1010];int cmp (const void *a,const void *b) {return (* (struct S *) b). bi-(* (struct S *) a). Bi; int main () {int n,m;while (scanf ("%d%d", &n,&m)!=eof) {int i,j;for (i=0;i<n;i++) {scanf ("%d", &a[i].li);} for (i=0;i<n;i++) {scanf ("%d", &a[i].bi);} Qsort (A,n,sizeof (a[0]), CMP), memset (Dp,0,sizeof (DP)), for (i=0;i<n;i++) {for (j=m;j>=1;j--) {Dp[j]=max (dp[j], dp[j-1]+a[i].li-(j-1) *a[i].bi);}} printf ("%d\n", Dp[m]);}}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Hdoj topic 2670 Girl Love Value (01 backpack)

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.