L1-079 天梯赛的善良 分数 20
获取map的第一个和最后一个元素,分别使用begin()和-- end()访问。
// 9'21"
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
map<int,int> hash;
for(int i = 1; i <= n; ++ i)
{
int tmp;
cin >> tmp;
hash[tmp] ++;
}
auto hi = hash.begin();
cout << hi->first << " " << hi->second << endl;
hi = -- hash.end();
cout << hi->first << " " << hi->second << endl;
return 0;
}
浙公网安备 33010602011771号