Hdu 5437 Alisha ' s Party (priority queue)

Source: Internet
Author: User

http://acm.hdu.edu.cn/showproblem.php?pid=5437

Good understanding of the topic, if violent words or timeouts, you can consider the priority queue can be very simple to solve the problem

1#include <queue>2#include <cstdio>3#include <cstring>4#include <algorithm>5 using namespacestd;6 structPoint {7     intX,id;8     CharMax201];9     BOOL operator< (ConstPoint & Q)ConstTen     { One         if(x==q.x)returnq.id<ID; A         returnx<q.x; -     } - }; thePoint pe[150001]; - intnex[150001],a[150001]; - intMain () - { +     intt,n,m,z,i,x,y,w; -      while(~SCANF ("%d",&t)) +     { A          while(t--) at         { -scanf" %d%d%d",&n,&m,&z); -memset (NEX,0,sizeof(NEX)); -              for(i=1; i<=n;i++) -             { -scanf"%s", pe[i].na); inscanf"%d",&pe[i].x); -Pe[i].id=i; to             } +              while(m--) -             { thescanf"%d%d",&x,&y); *nex[x]+=y; $             }Panax Notoginsengnex[n]=N; -             intans=1; thePriority_queue<point>que; +              for(i=1; i<=n;i++) A             { the Que.push (Pe[i]); +                  while(nex[i]--) -                 { $                     if(que.size () = =0) Break; $Point temp=que.top (); Que.pop (); -a[ans++]=temp.id; -                 } the             } -              while(z--)Wuyi             { thescanf"%d",&W); -                 if(z!=0) printf ("%s", pe[a[w]].na); Wu                 Elseprintf"%s\n", pe[a[w]].na); -             } About         } $     } -     return 0; -}

Hdu 5437 Alisha ' s Party (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.