Benches

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
4
6
1
1
1
1
Output
3 7
Input
1
10
5
Output
15 15
Input
3
6
1
6
5
Output
6 12
Input
3
7
1
6
5
Output
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.
题目大意:
输入n,m,表示有n个椅子,一会会有m个人来,接下来n行是每个椅子上的人数,输出是m个人来了之后椅子上最少可以坐多少个人,最多可以坐多少个人。
解题思路:
最多的人数显而易见,就是m个人坐在当前人数最多的椅子上。而最少的人数,则是使所有椅子上的人数走一样多,也就是用m个人让所有椅子人数都为当前最大的人数。这样操作,就会有以下情况:
1.m个人没补完,那min就为当前的最大值
2.正好补完,min也为当前的最大值
3.补完了还有剩余,那就每个椅子依次加一,直到都补完,min为此时的最大值
AC代码:

#include<stdio.h>
#include<cstdlib>
#include<cmath>
#include<iostream>
using namespace std;
const int N=1e5+10;
int a[N];
int main()
{
	int n,m,l,r,mid;
	cin >> n >> m;
	int ans=0,sum=0;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		ans=ans+a[i];  //所有人数的和 
		sum=max(sum,a[i]);//椅子上的最大人数 
	}
	int t=sum;
	sum+=m;//最大值已求出
	ans+=m;
	l=ans%n;
	ans=ans/n;
	if(l!=0)
	    ans+=1;
	ans=max(ans,t);
	printf("%d %d\n",ans,sum);
	return 0;
	
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值