Pagini recente » Statistici sdfgsd asdf (H7GhosT) | Monitorul de evaluare | Diferente pentru runda/lol_asd intre reviziile 4 si 2 | Diferente pentru runda/lol_asd intre reviziile 4 si 1 | Cod sursa (job #2553204)
#include <fstream>
using namespace std;
ifstream cin("elmaj.in");
ofstream cout ("elmaj.out");
int n, x, elmaj, f, s;
int main ()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin >> n;
cin >> x;
elmaj = x;
f = 1;
for ( int i = 1; i < n; ++i){
cin >> x;
if ( f == 0)
elmaj = x;
if (elmaj == x)
++f;
else
--f;
}
cin.close();
cout.close();
ifstream cin ("elmaj.in");
ofstream cout ("elmaj.out");
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
f = 0;
cin>>n;
for ( int i = 1; i <= n; ++i){
cin >> x;
if(x == elmaj)
++f;
}
if(f > n/2)
cout << elmaj << " " << f;
else
cout << "-1";
return 0;
}