Pagini recente » Cod sursa (job #1587656) | Istoria paginii runda/test_icrisop | Cod sursa (job #2857244) | Cod sursa (job #1601699) | Cod sursa (job #1026112)
// Elem_Maj.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<fstream>
using namespace std;
int n, x, a[1000010], max=0, nr;
int main()
{
//ifstream f("F:/andreea/Scoala/FMI 2013/probleme fac I/infoarena/Elem_Maj/Debug/elmaj.in");
//ofstream g("F:/andreea/Scoala/FMI 2013/probleme fac I/infoarena/Elem_Maj/Debug/elmaj.out");
ifstream f("elmaj.in");
ofstream g("elmaj.out");
f >> n;
for (int i = 1; i <= n; i++)
{
f >> x;
a[x]++;
if (a[x]>max)
{
max = a[x];
nr = x;
}
}
if (max >= n / 2 + 1)
g << nr << " " << max;
else
g << -1;
f.close();
g.close();
return 0;
}