hdu 3496 Watch The Movie(二维背包)

原创 2011年10月12日 16:31:27

Watch The Movie

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1822    Accepted Submission(s): 610

Problem Description
New semester is coming, and DuoDuo has to go to school tomorrow. She decides to have fun tonight and will be very busy after tonight. She like watch cartoon very much. So she wants her uncle to buy some movies and watch with her tonight. Her grandfather gave them L minutes to watch the cartoon. After that they have to go to sleep.
DuoDuo list N piece of movies from 1 to N. All of them are her favorite, and she wants her uncle buy for her. She give a value Vi (Vi > 0) of the N piece of movies. The higher value a movie gets shows that DuoDuo likes it more. Each movie has a time Ti to play over. If a movie DuoDuo choice to watch she won’t stop until it goes to end.
But there is a strange problem, the shop just sell M piece of movies (not less or more then), It is difficult for her uncle to make the decision. How to select M piece of movies from N piece of DVDs that DuoDuo want to get the highest value and the time they cost not more then L.
How clever you are! Please help DuoDuo’s uncle.

The first line of the input file contains a single integer t (1 ≤ t ≤ 10), the number of test cases, followed by input data for each test case:
The first line is: N(N <= 100),M(M<=N),L(L <= 1000)
N: the number of DVD that DuoDuo want buy. 
M: the number of DVD that the shop can sale.
L: the longest time that her grandfather allowed to watch.
The second line to N+1 line, each line contain two numbers. The first number is the time of the ith DVD, and the second number is the value of ith DVD that DuoDuo rated.

Contain one number. (It is less then 2^31.)
The total value that DuoDuo can get tonight.
If DuoDuo can’t watch all of the movies that her uncle had bought for her, please output 0.

Sample Input
1 3 2 10 11 100 1 2 9 1

Sample Output


import java.io.*;
import java.util.*;
public class Main
	public static int max(int a,int b)
		return a>b?a:b;
	public static void main(String arg[])
		Scanner cin=new Scanner(System.in);
		int oo=-1000000000;
		int mm=1111;
		int mn=111;
		int f[][]=new int[mn][mm],t[]=new int[mn],v[]=new int[mn];
		int i,j,k,n,m,l,T;

版权声明:本文为博主原创文章,未经博主允许不得转载。 http://blog.csdn.net/fp_hzq/article/details/6866894

HDU 3496 Watch The Movie (二维背包)

题意是 DuoDuo 想看n部电影,但是被要求最长能看的总时间数为 L ,每部电影有他的时长和DuoDuo对他的评价值 两个属性。 但是 商店有个奇怪的要求 一次只卖恰好 m 个电影碟 (m  ...
  • Night__elf
  • Night__elf
  • 2012年12月27日 09:45
  • 179

HDU 3496 Watch The Movie 二维背包

#include #include struct node { int v,t; }a[333]; int Max(int a,int b) { return a>b?a:b; }...
  • u012749539
  • u012749539
  • 2014年06月24日 23:01
  • 602

hdu 3496 Watch The Movie (二维背包)

Watch The Movie Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) ...
  • u011721440
  • u011721440
  • 2014年04月15日 20:39
  • 628

HDU 3496 Watch The Movie(二维背包)

Watch The Movie Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) ...
  • yao1373446012
  • yao1373446012
  • 2016年03月23日 14:08
  • 328

3496 Watch The Movie 二维背包

自己写的 #include #include #include using namespace std; int dp[1005][1005]; int n, t, m, l; int w[...
  • qqchenjunwei
  • qqchenjunwei
  • 2014年03月07日 21:42
  • 513

HDOJ 3496 Watch The Movie (二维背包)

题目链接:(—_—) zZ 题目大意:小明想要买n张碟子来看, 但商店只卖m张(m 思路:简单的二维费用背包问题, dp[j][k]表示时间为j内, 看k张碟子得到的最大价值。dp...
  • ulquiorra0cifer
  • ulquiorra0cifer
  • 2012年07月24日 22:24
  • 1147

hdu 3496 Watch The Movie (二维背包简单题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3496 解题报告:题目中有两个“花费”,典型的二维背包的问题 本题主要是推出状态转移方程,已...
  • ren_hui
  • ren_hui
  • 2013年08月02日 21:12
  • 425

HDU 3496 Watch The Movie (二维背包+01背包)

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3496 题意:有n部电影,给出他们的用时和价值,现在一定要看m部(不能多不能少),花的时间要少于等于l,...
  • u011065479
  • u011065479
  • 2013年07月16日 02:22
  • 1655

杭电 hdu 3496 Watch The Movie 二维背包

杭电 hdu 3496 Watch The Movie 二维背包 背包问题
  • panyanyany
  • panyanyany
  • 2011年08月06日 16:43
  • 771


题意:在N张CD中选M张出来,且选中CD播放时间总和不超过L。使喜欢度总和最大。 分析:简单二维01背包 #include #include #include #include using...
  • u013899738
  • u013899738
  • 2015年08月24日 15:38
  • 355
您举报文章:hdu 3496 Watch The Movie(二维背包)