#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
struct Student
{
char name_[15];
int solve;
} stu;
struct Greater
{
bool operator() (Student a, Student b)
{
return a.solve < b.solve;
}
};
struct Less
{
bool operator() (Student a, Student b)
{
return a.solve > b.solve;
}
};
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
priority_queue<Student, vector<Student>, Greater> MAX;
priority_queue<Student, vector<Student>, Less> MIN;
char str[20];
while (1)
{
scanf("%s", str);
if (strcmp(str, "Add") == 0)
{
scanf("%s%d", stu.name_, &stu.solve);
if(MAX.size() == MIN.size())
{
if (MAX.empty() || stu.solve < MIN.top().solve)
MAX.push(stu);
else if (stu.solve > MIN.top().solve)
{
MAX.push(MIN.top());
MIN.pop();
MIN.push(stu);
}
}
else if (MAX.size() > MIN.size())
{
if (stu.solve > MAX.top().solve)
MIN.push(stu);
else if (stu.solve < MAX.top().solve)
{
MIN.push(MAX.top());
MAX.pop();
MAX.push(stu);
}
}
}
else if (strcmp(str, "Query") == 0)
{
if (MIN.size() == MAX.size())
printf("No one!\n");
else
printf("%s\n", MAX.top().name_);
}
else if (strcmp(str, "End") == 0)
{
if (MIN.size() == MAX.size())
printf("Happy BG meeting!!\n");
else
printf("%s is so poor.\n",MAX.top().name_);
break;
}
}
if (T != 0)
printf("\n");
}
return 0;
}
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
struct Student
{
char name_[15];
int solve;
} stu;
struct Greater
{
bool operator() (Student a, Student b)
{
return a.solve < b.solve;
}
};
struct Less
{
bool operator() (Student a, Student b)
{
return a.solve > b.solve;
}
};
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
priority_queue<Student, vector<Student>, Greater> MAX;
priority_queue<Student, vector<Student>, Less> MIN;
char str[20];
while (1)
{
scanf("%s", str);
if (strcmp(str, "Add") == 0)
{
scanf("%s%d", stu.name_, &stu.solve);
if(MAX.size() == MIN.size())
{
if (MAX.empty() || stu.solve < MIN.top().solve)
MAX.push(stu);
else if (stu.solve > MIN.top().solve)
{
MAX.push(MIN.top());
MIN.pop();
MIN.push(stu);
}
}
else if (MAX.size() > MIN.size())
{
if (stu.solve > MAX.top().solve)
MIN.push(stu);
else if (stu.solve < MAX.top().solve)
{
MIN.push(MAX.top());
MAX.pop();
MAX.push(stu);
}
}
}
else if (strcmp(str, "Query") == 0)
{
if (MIN.size() == MAX.size())
printf("No one!\n");
else
printf("%s\n", MAX.top().name_);
}
else if (strcmp(str, "End") == 0)
{
if (MIN.size() == MAX.size())
printf("Happy BG meeting!!\n");
else
printf("%s is so poor.\n",MAX.top().name_);
break;
}
}
if (T != 0)
printf("\n");
}
return 0;
}