Pagini recente » Cod sursa (job #487806) | Cod sursa (job #1812134) | Cod sursa (job #2102730) | Cod sursa (job #2931689) | Cod sursa (job #1018321)
#include<iostream>
#include<fstream>
using namespace std;
int prez1[999999999];
int n,v[1000001],x,elem,i,poz=0,val[1000001],ok=0;
ifstream f("elmaj.in");
ofstream g("elmaj.out");
int main()
{
f>>n;
for (i=1; i<=n; i++)
{f>>x;
if (x>0)
if (prez1[x]==0)
{
poz++;
prez1[x]=poz;
v[poz]++;
val[poz]=x;
}
else v[prez1[x]]++;
// else
//{
// x=-x;
// if (prez2[x]==0)
// {
// poz++;
// prez2[x]=poz;
// v[poz]++;
// val[poz]=-x;
// }
// else v[prez2[x]]++;
//}
}
for (i=1; i<=poz; i++)
{
if (v[i]>=(n/2+1)) {ok=1; g<<val[i]<<" "<<v[i];}
}
if (ok==0) g<<"-1";
return 0;
}