Easy - zr学姐与迷弟
众所周知,zr学姐美丽动人,吸引了众多迷弟。迷弟那么多,他都快不好意思了!于是她打算请迷弟们喝奶茶。但是奶茶不够分啊!于是zr学姐想出了一个办法,把迷弟们的成绩搜集起来,排个序,成绩好的优先,嘿嘿。如果两个人成绩一样,就按照字典序的顺序进行排序。zr学姐去买奶茶了,你能帮她完成这个任务吗?
Input
第一行一个数字n(1 ≤ n ≤ 20)表示人数。 接下来n行每行一个字符串s(1 ≤ len(s) ≤ 20)和一个数字k(0 ≤ k ≤ 100),表示迷弟的名字和成绩。(字符串仅包含小写字母)
Output
输出排序之后的结果,每个字符串一行
Sample 1
Inputcopy | Outputcopy |
---|---|
15 myj 98 ddl 98 cd 98 hzy 98 ljz 100 wlk 59 kfccrazythursdayvme 50 cxk 38 dingzhenzhenzhu 0 dingzhen 0 donghuangtai 1 tiansuohao 2 jieerlian 3 renshengzigushui 54 iphone 14 |
ljz cd ddl hzy myj wlk renshengzigushui kfccrazythursdayvme cxk iphone jieerlian tiansuohao donghuangtai dingzhen dingzhenzhenzhu |
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
bool ELUOSI(pair<string,int>HUAWEI,pair<string,int>IPHONE)
{
if (HUAWEI.second==IPHONE.second)
{
return HUAWEI.first<IPHONE.first;
}
return HUAWEI.second>IPHONE.second;
}
int main()
{
int GUAILING;
cin >>GUAILING;
vector<pair<string, int>>WUKELAN(GUAILING);
for (int YUANSHEN=0;YUANSHEN<GUAILING;++YUANSHEN)
{
cin >>WUKELAN[YUANSHEN].first>>WUKELAN[YUANSHEN].second;
}
sort(WUKELAN.begin(),WUKELAN.end(),ELUOSI);
for (int YUANSHEN=0;YUANSHEN<GUAILING;++YUANSHEN)
{
cout <<WUKELAN[YUANSHEN].first<<endl;
}
return 0;
}