# Additional questions for spring intern recruitment in Baidu 2015 _ have a good day !, Spring 2015

Source: Internet
Author: User

Additional questions for spring intern recruitment in Baidu 2015 _ have a good day !, Spring 2015

When I worked overtime for an all-night Dudu Xiong, I felt a little nervous. I thought of bugs that could not be solved, and my tears could not help but burst down ...... He looked up and looked at the gray sky of the imperial capital. He bit his teeth and put his foot in a bid and shouted-the labor and capital must be ready today! We know that there are n canteens in our factory, and I (I belongs to [1, n]) canteens have m [I] kinds of food. Each type of food has a price c, enjoy v, du duxiong wants to go to a dining room and spend money in the range of [bot, top] (you can also pat the table and leave without eating any food, maximize your enjoyment. (Note: Dudu Xiong also has a feature of picky eaters, which can be ordered at most once .) Now I want to tell you all the information about the food in the canteen. I hope you can make a selection and match them so that Dudu bears can enjoy the greatest enjoyment and output the value of this enjoyment.
Input description:

The first line is a positive integer T (1 <= T <= 20), indicating that there are T groups of test data.
For each group of data --
The first row contains three numbers: n, bot, top, and n, indicating the number of canteens: 1 <= n <= 10). bot is the lowest consumption for this meal, top is the highest consumption for this meal (0 <= bot, top <= 10000)
The next step is the information about n canteens.
The first row is a number m [I] (o <= m [I] <= 100), representing the number of foods in the I canteen
The second row has 2 * m [I] numbers, which are c [I] [1], v [I] [1], c [I] [2], v [I] [2],... C [I] [m [I], v [I] [m [I]
C [I] [j] indicates the price of the j type of food in the I-th restaurant, v [I] [j] represents the enjoyment brought to Dudu Xiong by j foods in the I-th restaurant.

Output description:

For each group of data, output a row with a positive integer in each row. It indicates the maximum level of enjoyment that the dual bears can obtain.
The data result cannot exceed 2 ^ 31-1.

Input example:

2
2 10 20
5 1 1 2 1 5 1 10 1 20 1
5 1 2 2 2 5 2 10 2 20 2
2 10 10
1 5 1
1 5 1

Output example:

8

0

01 the backpack problem is a classic dp

`#include <iostream>#include <cstring>#include <cmath>using namespace std;int ans[10010];int main(){int T,n,bot,top,m,c,v,i,k;cin>>T;while(T--){cin>>n>>bot>>top;k=0;while(n--){memset(ans,0,sizeof(ans));cin>>m;while(m--){cin>>c>>v;for(i=top;i>=c;i--)if((ans[i-c]>0) || (0==i-c))ans[i]=max(ans[i],ans[i-c]+v);}for(i=bot;i<=top;i++)k=max(k,ans[i]);}cout<<k<<endl;}return 0;}`

Related Keywords:

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.