pku 2051 Argus(优先队列)

#include <iostream> #include <queue> using namespace std; struct node { int time,Q_num,Period; }; //struct cmp //{ // bool operator()(const node& a,const node& b) // { // if(a.time!=b.time) return a.time>b.time; // else return a.Q_num>b.Q_num; // } //}; //priority_queue<node,vector<node>,cmp> task; bool operator>(const node& a,const node& b) { if(a.time!=b.time) return a.time>b.time; else return a.Q_num>b.Q_num; } priority_queue<node,vector<node>,greater<vector<node>::value_type>> task; int main() { node temp; int K; char operation[10]; for(int i=0;;i++) { scanf("%s",operation); if(operation[0]=='R') { scanf("%d%d",&temp.Q_num,&temp.Period); temp.time=temp.Period; task.push(temp); } else break; } scanf("%d",&K); while(K--) { temp=task.top(); printf("%d/n",temp.Q_num); temp.time+=temp.Period; task.pop(); task.push(temp); } return 0; }  

你可能感兴趣的:(include)