Răspuns:
#include<bits/stdc++.h>
using namespace std;
int main()
{
ifstream f("maxim4.in");
ofstream g("maxim4.out");
int n,a,nr=0,maxx=0;
f>>n;
while(n)
{
f>>a;
if(a==maxx)
nr++;
else if(a>maxx)
{
maxx=a;
nr=1;
}
n--;
}
g<<maxx<<" "<<nr;
return 0;
}
Explicație: