Codevs 1052 Ground mouse game priority queue

Source: Internet
Author: User
Tags gopher

1052 Ground Mouse Games

Time limit:1 Sec Memory limit:256 MB

Topic Connection http://www.codevs.cn/problem/1052/
Description

Wang Gang is a student of excellent academic performance, in peacetime learning, he can always use all the time to study seriously and efficiently, he not only study hard, but also good at often summarize, improve their learning methods, so he always in every exam to get excellent scores, which is largely because he is a pursuit of efficiency of the people.

But Wang Gang is also a like to play, usually in school he tried to restrain himself to play, but in Sunday he will smoke a certain time to let himself play, his father and mother also more trust in his learning ability and learning habits, so in Sunday will not like other parents on his grasp, Instead, he was allowed to spend his free time in the morning of Sunday.

The Gopher game is a game that requires speed and agility in response. At the beginning of the game, there will be a lot of rats on the floor, and then when you use a hammer to tap these hamsters, each hamster is hit, will increase the corresponding game score. The problem is that these hamsters will not wait for you to knock, it will always come out after a while to drill under the floor (and never come up), each hamster to stay after the time may be different, and each ground mouse is hit after the increased game score may be different, in order to win, Game participants have to selectively tap some hamsters as soon as possible, depending on the characteristics of each gopher, making the total score the most.

This challenging game Wang gang especially liked, recently he often played this game in Sunday morning, slowly he not only hit faster and faster (the time required to tap each gopher is 1 seconds), and he also found some features of the game, that is, every time the game starts again, A hamster's time to stay is fixed, and he records the number of points that will be added to each hamster when struck. As a result, he always chooses to hit different hamsters at the beginning of each game, ensuring that the maximum score is obtained each time.

Input inputscontains 3 rows, the first row contains an integer n(1<=n<=100) that indicates that n hamsters are emitting from the ground, and the second row n A space-delimited integer indicates how long each gopher stays, and the third row of n spaces-separated integers represents the added score (<=100) for each gopher to be struck. the number of I in each row represents The information of the I gopher. Output outputs have only one line of integers, which represents the maximum game score that Wang Gang can get. Sample Input

5

5 3 6) 1 4

7 9 2) 1 5

Sample Output24
HINT

Test instructions

Exercises

Maintain a large heap, the time from the maximum start, each time the upper limit for this time to add to the point, and then choose a maximum weight of the hit is good

Code:

//Qscqesze#include <cstdio>#include<cmath>#include<cstring>#include<ctime>#include<iostream>#include<algorithm>#include<Set>#include<vector>#include<sstream>#include<queue>#include<typeinfo>#include<fstream>#include<map>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineMAXN 200001#defineMoD 10007#defineEPS 1e-9//const int INF=0X7FFFFFFF; //infinitely LargeConst intinf=0x3f3f3f3f;/*inline ll read () {int X=0,f=1;char ch=getchar (); while (ch< ' 0 ' | |    Ch> ' 9 ') {if (ch== '-') F=-1;ch=getchar ();}    while (ch>= ' 0 ' &&ch<= ' 9 ') {x=x*10+ch-' 0 '; Ch=getchar ();} return x*f;}  int buf[10];inline void Write (int i) {int p = 0;if (i = = 0) p++;  else while (i) {buf[p++] = i% 10;i/= 10;}  for (int j = p-1; J >=0; j--) Putchar (' 0 ' + buf[j]); printf ("\ n");}*///**************************************************************************************structnode{intx, y; FriendBOOL operator<(node A,node b) {returna.y<b.y; }};node A[MAXN];p riority_queue<node>Q;intMain () {intN; CIN>>N; intt=0;  for(intI=0; i<n;i++) {cin>>a[i].x; T=Max (a[i].x,t); }     for(intI=0; i<n;i++) {cin>>a[i].y; }    intans=0; //cout<<t<<endl;     for(inti=t;i;i--)    {         for(intj=0; j<n;j++)            if(a[j].x==i) Q.push (A[j]); if(!Q.empty ()) {ans+=q.top (). Y;        Q.pop (); }} cout<<ans<<Endl;}

Codevs 1052 Ground mouse game priority queue

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.