typedef int score_t;
typedef int count_t;
#include <map>
#include <iostream>
#include <vector>
int main()
{
std::map<score_t, count_t> data;
// step1: input: use ctrl-z to end
for (score_t tmp; std::cin >> tmp;)
{
++data[tmp];
}
// step2: get identical number
std::vector<score_t> most_appeared;
count_t max;
std::map<score_t, count_t>::iterator i = data.begin();
most_appeared.push_back(i->first);
max = i->second;
for (++i;
i != data.end(); ++i)
{
if (i->second > max)
{
max = i->second;
most_appeared.clear();
most_appeared.push_back(i->first);
}
else if (i->second == max)
{
most_appeared.push_back(i->first);
}
else continue;
}
// step 3: output
std::cout << "The highest score is: " << data.rbegin()->first << std::endl;
std::cout << "The lowest score is: " << data.begin()->first << std::endl;
std::cout << "The identical score"
<< (most_appeared.size() > 1 ? "s are: " : " is");
for (int i = 0; i != most_appeared.size(); ++i)
{
std::cout << most_appeared[i] << " ";
}
return 0;
}
/*
see <c++ primer> 4th
section 10.3.4#Programming Implications of the Subscript Behavior
*/
CnR5cGVkZWYgaW50IHNjb3JlX3Q7CnR5cGVkZWYgaW50IGNvdW50X3Q7CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KaW50IG1haW4oKQp7CnN0ZDo6bWFwPHNjb3JlX3QsIGNvdW50X3Q+IGRhdGE7CgovLyBzdGVwMTogaW5wdXQ6IHVzZSBjdHJsLXogdG8gZW5kCmZvciAoc2NvcmVfdCB0bXA7IHN0ZDo6Y2luID4+IHRtcDspCnsKCSsrZGF0YVt0bXBdOwp9Ci8vIHN0ZXAyOiBnZXQgaWRlbnRpY2FsIG51bWJlcgpzdGQ6OnZlY3RvcjxzY29yZV90PiBtb3N0X2FwcGVhcmVkOwpjb3VudF90IG1heDsKc3RkOjptYXA8c2NvcmVfdCwgY291bnRfdD46Oml0ZXJhdG9yIGkgPSBkYXRhLmJlZ2luKCk7Cm1vc3RfYXBwZWFyZWQucHVzaF9iYWNrKGktPmZpcnN0KTsKbWF4ID0gaS0+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