- 水王争霸
- 2017-10-09 15:37:35 @
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
struct Player
{
char ID[20];
long tieCount;
};
bool IDcmp(Player p1,Player p2)
{
if (strlen(p1.ID) < strlen(p2.ID))return true;
if (strlen(p1.ID) > strlen(p2.ID))return false;
return false;
}
bool tiecmp(Player p1, Player p2)
{
if (p1.tieCount>p2.tieCount)return true;
if (p1.tieCount < p2.tieCount)return false;
if (p1.tieCount == p2.tieCount) return IDcmp(p1, p2);
return false;
}
int main()
{
int playercount = 0;
cin >> playercount;
Player p[100];
for (int i = 0; i < playercount; i++)
{
cin >> p[i].ID >> p[i].tieCount;
}
sort(p, p + playercount, tiecmp);
for (int i = 0; i < playercount; i++)
{
cout << p[i].ID << endl;
}
}