58 lines
890 B
C++
58 lines
890 B
C++
/*
|
|
VIM: let g:lcppflags="-std=c++11 -O2 -pthread"
|
|
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
|
|
VIM: let g:argv=""
|
|
*/
|
|
#include <iostream>
|
|
#include <stdexcept>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
#include <string>
|
|
|
|
int solution( std::vector<int> & a )
|
|
{
|
|
int max_e = 10001; //
|
|
std::vector<int> c(max_e, 0);
|
|
|
|
for ( auto e : a ) {
|
|
++c[e];
|
|
}
|
|
|
|
int m = 0;
|
|
int mi = 0;
|
|
for ( auto it = c.begin(); it != c.end(); ++it ) {
|
|
if (*it > m)
|
|
{
|
|
m = *it;
|
|
mi = it - c.begin();
|
|
}
|
|
}
|
|
return mi;
|
|
}
|
|
|
|
int main ( void )
|
|
{try{
|
|
#if 1
|
|
std::vector<int> a = {
|
|
0, 0, 1, 2, 0, 10000, 10000, 10000
|
|
};
|
|
|
|
std::cout << solution( a ) << std::endl;
|
|
|
|
#endif
|
|
return 0;
|
|
}
|
|
catch ( const std::exception& e )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
|
return 2;
|
|
}
|
|
catch ( ... )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "unknown exception." << std::endl;
|
|
return 1;
|
|
}}
|
|
|