临平建设局网站,天津西青区邮政编码,wordpress用户投稿单页,福州网站建设流程题意#xff1a;给定一个阿格斯系统#xff0c;每个period周期都会产生一次编号为Q_num的事件#xff0c;任务是模拟前k个事件。 思路#xff1a;直接按照优先队列的方法来模拟和构造即可。 code#xff1a; #include bits/stdc.h
using namespace std;struct nod…题意给定一个阿格斯系统每个period周期都会产生一次编号为Q_num的事件任务是模拟前k个事件。 思路直接按照优先队列的方法来模拟和构造即可。 code #include bits/stdc.h
using namespace std;struct node
{int qnum,period,time;bool operator (const node a) const {return timea.time||(timea.timeqnuma.qnum);}
};int main()
{priority_queuenodepq;char s[25];while (scanf(%s,s)s[0]!#){node t;scanf(%d%d,t.qnum,t.period);t.timet.period;pq.push(t);}int k;scanf(%d,k);for (int i0;ik;i){node rpq.top();pq.pop();printf(%d\n,r.qnum);r.timer.period;pq.push(r);}
}