HDU5437 Alisha's Party (priority queue + simulation)

Source: Internet
Author: User

HDU5437 Alisha's Party (priority queue + simulation)
Source 2015 ACM/ICPC Asia Regional Changchun Online question: k people bring a gift of value vi to open the door m times. Every time t people come, open the door and put in p people, when everyone came, they opened the door again to bring the rest of the people into the room. Every time there were people with high gift values, they came first with the same value. q times asked, ask the name of the nth incoming person.
Analysis: priority queue + simulation is acceptable, but note that m can be 0.

#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include
      #include 
       
        #include 
        
         #include 
         
          #include using namespace std;const double eps = 1e-6;const double pi = acos(-1.0);const int INF = 0x3f3f3f3f;const int MOD = 1000000007;#define ll long long#define CL(a,b) memset(a,b,sizeof(a))#define lson (i<<1)#define rson ((i<<1)|1)#define MAXN 150010struct node{ int id,v; char name[220]; bool operator < (const node &tmp) const { if(v == tmp.v) return id < tmp.id; return v > tmp.v; }}p[MAXN];struct opendoor{ int a,b; bool operator < (const opendoor &tmp) const { return a < tmp.a; }}od[MAXN];set
          
            s;int query[110];int main(){ int T,n,m,q; scanf("%d",&T); while(T--) { s.clear(); scanf("%d%d%d",&n,&m,&q); for(int i=1; i<=n; i++) { scanf("%s %d",p[i].name, &p[i].v); p[i].id = i; } for(int i=0; i
           
             ans; int cnt = 0; for(int i=1; i<=n&&ans.size()
            
             id); s.erase(s.begin()); } cnt++; } } while(!s.empty() && ans.size()
             
              id); s.erase(s.begin()); } for(int i=0; i
              
             
            
           
          
         
        
       
     
    
   
  
 


Related Article

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.