A. Benches
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
There are nn benches in the Berland Central park. It is known that aiai people are currently sitting on the ii-th bench. Another mm people are coming to the park and each of them is going to have a seat on some bench out of nn available.
Let kk be the maximum number of people sitting on one bench after additional mm people came to the park. Calculate the minimum possible kk and the maximum possible kk.
Nobody leaves the taken seat during the whole process.
Input
The first line contains a single integer nn (1≤n≤100)(1≤n≤100) — the number of benches in the park.
The second line contains a single integer mm (1≤m≤10000)(1≤m≤10000) — the number of people additionally coming to the park.
Each of the next nn lines contains a single integer aiai (1≤ai≤100)(1≤ai≤100) — the initial number of people on the ii-th bench.
Output
Print the minimum possible kk and the maximum possible kk, where kk is the maximum number of people sitting on one bench after additional mm people came to the park.
Examples
input
Copy
4 6 1 1 1 1
output
Copy
3 7
input
Copy
1 10 5
output
Copy
15 15
input
Copy
3 6 1 6 5
output
Copy
6 12
input
Copy
3 7 1 6 5
output
Copy
7 13
Note
In the first example, each of four benches is occupied by a single person. The minimum kk is 33. For example, it is possible to achieve if two newcomers occupy the first bench, one occupies the second bench, one occupies the third bench, and two remaining — the fourth bench. The maximum kk is 77. That requires all six new people to occupy the same bench.
The second example has its minimum kk equal to 1515 and maximum kk equal to 1515, as there is just a single bench in the park and all 1010 people will occupy it.
AC代码(最多的可能一定是人数最多的椅子上的人+m, 最少的可能要分类讨论
1、假设所有的凳子都和人数最多的那个凳子做一样的人数这个和>m那么最少的可能是人数最多的椅子上的人数
2、所有凳子都做和人数最多的拿个凳子一样的人仍然坐不下m个人那就把剩下的人平均分配再找出人数最多的凳子)
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int n, m, a[120], i, maxi = 0, sm = 0, mini; scanf("%d %d",&n, &m); int f = m; for(i = 0;i<n;i++) { scanf("%d",&a[i]); if(a[i]>maxi) maxi = a[i]; } for(i = 0;i<n;i++) { sm = sm+maxi-a[i]; } if(sm>=m) mini = maxi; else { m = m-sm; int k = m%n; m = m/n; if(k>0) m++; mini = maxi+m; } maxi = maxi+f; printf("%d %d\n",mini, maxi); return 0; }