Pagini recente » Cod sursa (job #3352150) | Cod sursa (job #1456577) | Cod sursa (job #2847479) | Cod sursa (job #2513875) | Cod sursa (job #1060788)
#include <cstdio>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <set>
#include <stack>
#include <unordered_map>
using namespace std;
void print_sol(long long x,int nr)
{
ofstream g("elmaj.out");
if(x == -1)
g<<x;
else
g<<x<<" "<<nr;
g.close();
}
int main()
{
unordered_map<long long,int> hash;
ifstream f("elmaj.in");
int N;
long long x;
f>>N;
for(int i=1;i<=N;++i)
{
f>>x;
if(hash.find(x) != hash.end())
++hash[x];
else
hash[x] = 1;
if(hash[x] > N/2)
{
print_sol(x, hash[x]);
return 0;
}
}
print_sol(-1, 0);
return 0;
}