宇宙总统
题目描述
地球历公元 6036 年,全宇宙准备竞选一个最贤能的人当总统,共有 n n n 个非凡拔尖的人竞选总统,现在票数已经统计完毕,请你算出谁能够当上总统。
输入格式
第一行为一个整数 n n n,代表竞选总统的人数。
接下来有 n n n 行,分别为第一个候选人到第 n n n 个候选人的票数。
输出格式
共两行,第一行是一个整数 m m m,为当上总统的人的号数。
第二行是当上总统的人的选票。
样例 #1
样例输入 #1
5
98765
12365
87954
1022356
985678
样例输出 #1
4
1022356
提示
票数可能会很大,可能会到 100 100 100 位数字。
1 ≤ n ≤ 20 1 \leq n \leq 20 1≤n≤20。
AC代码:
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<queue>
#include<string>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<numeric>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int>PII;
const int N=3e5+10;
const int MOD=998244353;
const int INF=0X3F3F3F3F;
const int dx[]={-1,1,0,0,-1,-1,+1,+1};
const int dy[]={0,0,-1,1,-1,+1,-1,+1};
const int M = 1e6 + 10;
struct hou{
string a;
int b;
bool operator <(const hou & u) const
{
if(a.size() == u.a.size()) {
return a < u.a;
}
else return a.size() < u.a.size();
}
}s[1010];
int main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i ++)
{
cin >> s[i].a;
s[i].b = i;
}
sort(s + 1, s + 1 + n);
cout <<s[n].b << endl << s[n].a << endl;
return 0;
}