Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("maximpar.in");
ofstream g("maximpar.out");
int n, a, maxim, apare=-1, i, ap=0;
f >> n >> a;
if (a%2==0) { maxim=a; apare=1; ap=1; i=1;}
else
{
i=1;
while (a%2 && i<n)
{
f >> a;
++i;
}
if (i<=n && a%2==0)
{
ap=1; maxim=a; apare=1;
}
}
if (ap)
{
while (i<n)
{
f >> a;
++i;
if (a%2==0)
{
if (a>maxim) { maxim=a; apare=1; }
else if (a==maxim) ++apare;
}
}
g << maxim << " " << apare << endl;
}
else g << -1 << endl;
f.close(); g.close();
return 0;
}
Explicație: