蒟蒻在看P1427题解的时候
看到第一个大佬介绍了一种用优先队列实现的方法
他这里的比较函数为什么要让他return false啊(即为什么要return x.time<y.time而不是return x.time>y.time)
#include<iostream>
#include<queue>
using namespace std;
struct node{
int time;
int value;
}t;
priority_queue<node> a;
bool operator<(const node &x,const node &y){
return x.time<y.time;
}
int c,n;
int main(){
while(1){
cin>>c;
if(c==0) break;
n++;
t.value=c;
t.time=n;
a.push(t);
}
while(!a.empty()){
cout<<a.top().value<<" ";
a.pop();
}
return 0;
}