-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush7pa.cpp
More file actions
37 lines (36 loc) · 805 Bytes
/
push7pa.cpp
File metadata and controls
37 lines (36 loc) · 805 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int tc, n, max = 0, h, count = 1;
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)
max = ar[n - 1];
else
{
for (int i = 0; i < n; i++)
{
if (ar[i] == ar[i + 1])
count++;
else
{
h = ar[i] + (count - 1);
count = 0;
if (h > max)
max = h;
}
}
}
cout << max << endl;
--tc;
}
return 0;
}