CODEVS 1025 and codevs1025

Source: Internet
Author: User

CODEVS 1025 and codevs1025
DescriptionDescription

The Farmer's Canteen (NM Canteen), The best dining room of PK University, is not far from The dormitory of Komatsu ). Because the food in the canteen is good and the price is fair, many people like to come here for dinner. The Farmer's Canteen ordering method is just like choosing a product in a supermarket. People go in from a designated intersection, come out from a designated intersection, and pay for it. As there are a large number of people dining here, people consciously lined up at the entrance to choose food along a long table with various dishes.

Mr. Komatsu found that this food selection method means that he cannot leave the team to pick up some dishes he has already seen or not seen during the course selection, because it is impolite to jump into the queue, it is also BS.

Each dish has a value, and Komatsu also sets a delicious value for each dish. For example, braised yellow croaker is very valuable to Komatsu, in the eyes of Komatsu, cauliflower is a delicious dish with extremely low value. Some dishes have extremely high nutritional value (such as rice), so no matter what the value of its delicious food is, Xiao song will choose one. Xiaosong now hasXYuan to eat in the canteen, he wants to know, inNo overdue accountUnder the circumstances, the most delicious value of his choice is.

Input descriptionInput Description

Read the relevant data from the input file farmer. in. The first line of the input contains two integers.N(1≤ N≤100 ),K(0≤K≤Type of the actual dish) and a real numberX(0≤ X≤100), indicating thatNDishes, includingKIt is required to grow vegetables.XYuan (accurate to "Corner "). The following line containsNNumber of real numbers, indicating the price of all dishes from the entrance to the exit (0≤Price≤10, in the unit of "Yuan", accurate to "angle"); then the next line containsNIt indicates the value of all the dishes on the menu from the entrance to the exit (0≤Delicious Value≤100); the next line containsNNumber of all types of dishes from the entrance to the exit (1≤Type Number≤100 ). The last line containsKIntegers,Indicating the requiredType Number. Note that the same number of dishes can appear multiple times, but their prices and value are the same. For the same dish (whether required or not), Komatsu can select only one dish at most (it is boring to buy two braised tofu dishes ). In addition, the price of the required course must not exceedX.

Output description Output Description

Output the result to the output file farmer. out. The output contains an integer indicating the maximum value of the food that Mr. Komatsu can select.

Note: you can assume that the data does not show that the money provided by Komatsu is insufficient for food purchase.

 

Sample InputSample Input

7 1 5.0

4 1 3 0.9 2 0.5 0.9

7 3 5 2 5 0 2

6 3 5 2 4 1 2

2

Sample outputSample Output

10

Data range and prompt Data Size & Hint
#include<iostream>using namespace std;int v[101]={0},c[101]={0},w[101]={0},f[10011]={0},n,m,k,x,mx=0,maxn=0,visi[101]={0};double a,b;int main(){    cin>>n>>m>>b;    x=(int)(b*10);    for(int i=1;i<=n;i++)         cin>>a,v[i]=(int)(a*10);    for(int i=1;i<=n;i++)         cin>>w[i];    for(int i=1;i<=n;i++)    {        cin>>k;        visi[k]++;        if(visi[k]>1) v[i]=w[i]=0;        else c[k]=i;    }    for(int i=1;i<=m;i++)     {         cin>>k;        mx+=w[c[k]];        x-=v[c[k]];         w[c[k]]=v[c[k]]=0;    }      for(int i=1;i<=n;i++)        for(int j=x;j>=v[i];j--)        {               f[j]=max(f[j],f[j-v[i]]+w[i]);               maxn=max(maxn,f[j]);        }     cout<<maxn+mx; }
View Code

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.