#include <stdio.h>#include <string.h>#include <queue>#include <algorithm>using namespace STD;structnode{intNumintTintNowfriend BOOL operator< (node N1,node n2) {if(N1.now==n2.now)returnn2.num<n1.num;returnn2.now<n1.now; }}tp;priority_queue<node>q;intMain () {intcnt,i,n,top,num,t,k,amt=0;Chars[ -]; while(!q.empty ()) Q.pop (); while(~scanf('%s ', s)) {if(strcmp(S,"#")==0) {cnt=0;scanf("%d", &k); while(cnt<k) {tp=q.top (); Q.pop (); T=tp.now;printf("%d\n", Tp.num); cnt++; tp.now+=tp.t; Q.push (TP); while(T==q.top (). now&&cnt<k) {tp=q.top (); Q.pop ();printf("%d\n", Tp.num); cnt++; tp.now+=tp.t; Q.push (TP); } } while(!q.empty ()) Q.pop (); }Else{scanf("%d%d", &num,&t); Tp.num=num; tp.t=t; tp.now=t; Q.push (TP); } }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Fzu 1182 Argus Priority queue