学习了stl的list的部分用法
http://blog.csdn.net/ultimater/article/details/9195729
#include<cstdio>
#include<iostream>
#include<cstring>
#include<list>
#include<string>
#include<algorithm>
using namespace std;
struct Node
{
string name;
int grade;
int time;
Node(string nn="",int gg=0,int tt=0)
{
name=nn;
grade=gg;
time=tt;
}
friend bool operator<(Node a,Node b)
{
if(a.grade!=b.grade)
return a.grade<b.grade;
else
return a.time<b.time;
}
friend bool operator==(Node a,Node b)
{
return a.grade>=b.grade;
}
};
int main()
{
int t;
int cas=1;
int n;
char s[10];
cin>>t;
while(t--)
{
list<Node> l;
cin>>n;
printf("Case #%d:\n",cas++);
for(int i=0;i<n;i++)
{
cin>>s;
if(s[0]=='A')
{
Node temp;
cin>>temp.name>>temp.grade;
temp.time=i;
l.push_back(temp);
l.sort();
cout<<l.size()<<endl;
}
else
{
int num;
cin>>num;
list<Node>::iterator it=find(l.begin(),l.end(),Node("",num,0));
if(it==l.end())
cout<<"WAIT..."<<endl;
else
{
cout<<it->name<<endl;
l.erase(it);
}
}
}
}
return 0;
}