P2430 rigorous training

 

Topic background

Lj friends WKY is a fantastic boy, has a very high status among their peers. . .

Title Description

His teacher Pharaoh on his program level amazed, so determined to cultivate the name of the kid.

Pharaoh's training very strange way, he will make breath WKY do a lot of questions, asking him to complete the stipulated time. And Pharaoh to let his prestige increase, they themselves would put these questions are to do it again.

WKY and Pharaoh had a value level, their level is inversely proportional to the value of the ratio and the ratio of time spent doing these problems are. For example, if the level of WKY value is 1, the level of Pharaoh value is 2, then WKY doing the same questions time is 2 times of the Pharaohs.

Each topic has knowledge to which he belongs, which we all know, such as recursion, dynamic return, shortest path, network flow. Here we do not consider these things, we only know that they are knowledge points 1, 2 ...... knowledge points each corresponding to his knowledge difficult, such as dynamic programming is often difficult to simulate.

And every topic under the same knowledge, for WKY concerned, is the same difficulty. Made each question, Pharaoh has its own unique rewards value. The knowledge of the subject and value of prizes are not necessarily linked.

WKY now ask you to help the students, Wang calculated within the prescribed time, WKY can get the maximum bonus value is.

Input Format

Enter the document include the following:

first row:

WKY level values ​​and level values ​​Pharaoh.

Ensure that the level data value is less than the level of WKY Pharaoh value (even if it is unrealistic), and Wang level value is an integer multiple of the horizontal value WKY.

second line:

Total Number of m and n knowledge of the subject.

The third row:

n integers. I-th integer Pharaoh in the time required to do the i-th subject knowledge points.

Then there are m rows each of which includes two integers p, q. p represents knowledge of the subject belongs, q represents an incentive value corresponding to that topic.

The last line is a specified time.

Output Format

The output file is only one line, represents the maximum award value to be able to get.

Sample input and output

Input # 1
1 2
6 4
1 2 3 4
1 5
2 6
3 3
4 8
3 3
4 5
20
Output # 1
22

Description / Tips

To 100% of the data, the total number of the title <= 5000, a predetermined time <= 5000

 

 

 

01 backpack is essentially

 1 #include<cstdio>
 2 #include<iostream>
 3 using namespace std;
 4 int sp1,sp2;
 5 int m,n,i,j;
 6 int t,timee[10000];
 7 int all_time,f[10000];
 8 struct node{
 9     int zsd,jlz;
10 };
11 struct node c[10000];
12 int main()
13 {
14     scanf("%d%d",&sp1,&sp2);
15     scanf("%d%d",&m,&n);
16     for(i=1;i<=n;i++)
17     {
18         scanf("%d",&t);
19         timee[i]=t*sp2/sp1;
20     }
21     for(i=1;i<=m;i++)
22     {
23         scanf("%d%d",&c[i].zsd,&c[i].jlz );
24         c[i].zsd=timee[c[i].zsd];
25     }
26     scanf("%d",&all_time);
27     for(i=1;i<=m;i++)
28     for(j=all_time;j>=c[i].zsd;j--)
29     f[j]=max(f[j],f[j-c[i].zsd ]+c[i].jlz );
30     printf("%d",f[all_time]);
31     return 0;
32 }

 

 

Guess you like

Origin www.cnblogs.com/fuxiqi/p/11374217.html
Recommended