-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1873E.cpp
48 lines (46 loc) · 946 Bytes
/
1873E.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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n, c, total;
cin >> n >> c;
int columns[n];
for (int i = 0; i < n; i++)
{
cin >> columns[i];
}
int max = *max_element(columns, columns + n);
int h = max;
for (int i = 0; i < n; i++)
{
total += max - columns[i];
}
if (total < c)
{
h = h + ((c - total) / n);
}
else
{
while (1)
{
int total2 = 0;
for (int i = 0; i < n; i++)
{
total2 += max - columns[i];
}
max--;
if (total2<=c)
{
break;
}
}
h=max;
}
cout << h << endl;
}
return 0;
}