-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1117A.cpp
65 lines (58 loc) · 1.04 KB
/
1117A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,a[100005],sum=0,c[100005];
cin >> n;
if(n==1)
{
cin >> a[0];
cout << 1 << endl;
return 0;
}
else if(n==2)
{
cin >>a[0];
cin >> a[1];
if(a[0]==a[1])
{
cout << 2 << endl;
return 0;
}
else
{
cout << 1 << endl;
return 0;
}
}
else{
for(int i=0; i<n; i++)
{
cin >> a[i];
c[i]=a[i];
}
sort(a,a+n);
long long int maximum = a[n-1];
int count =0,j=0;
int b[10003];
for(int i=0; i<n; i++)
{
if(c[i]==maximum)
{
count++;
//cout << count << endl;
}
else
{
b[j]=count;
j++;
count=0;
}
}
b[j]=count;
//cout << b[j] << endl;
sort(b,b+j+1);
cout << b[j] << endl;
}
return 0;
}