-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpushpa.cpp
39 lines (38 loc) · 855 Bytes
/
pushpa.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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int tc, n;
cin >> tc;
while (tc > 0)
{
cin >> n;
int ar[n];
for (int i = 0; i < n; i++)
cin >> ar[i];
int s = sizeof(ar) / sizeof(ar[0]);
sort(ar, ar + s, greater<int>());
if (n == 1)
cout << ar[0] << endl;
else
{
int max = 0, count = 0;
for (int i = 0; i < n - 1; i++)
{
if (ar[i] == ar[i + 1])
count++;
else
{
if (max < ar[i] + count)
{
max = ar[i] + count;
}
count = 0;
}
}
cout << max << endl;
}
--tc;
}
return 0;
}