CF1042A Benches

原题链接:http://codeforces.com/contest/1042/problem/A

Benches

There are n n n benches in the Berland Central park. It is known that a i a_i ai people are currently sitting on the i i i-th bench. Another m m m people are coming to the park and each of them is going to have a seat on some bench out of n n n available.

Let k k k be the maximum number of people sitting on one bench after additional m m m people came to the park. Calculate the minimum possible k k k and the maximum possible k k k.

Nobody leaves the taken seat during the whole process.

Input

The first line contains a single integer n ( 1 ≤ n ≤ 100 ) n(1≤n≤100) n(1n100) — the number of benches in the park.

The second line contains a single integer m ( 1 ≤ m ≤ 10000 ) m(1≤m≤10000) m(1m10000) — the number of people additionally coming to the park.

Each of the next n n n lines contains a single integer a i ( 1 ≤ a i ≤ 100 ) a_i(1≤a_i≤100) ai(1ai100) — the initial number of people on the i i i-th bench.

Output

Print the minimum possible k k k and the maximum possible k k k, where k k k is the maximum number of people sitting on one bench after additional m m m 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 k k k is 3 3 3. 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 k k k is 7 7 7. That requires all six new people to occupy the same bench.

The second example has its minimum k k k equal to 15 15 15 and maximum k k k equal to 15 15 15, as there is just a single bench in the park and all 10 10 10people will occupy it.

题解

我都不知道我为什么要排序 (可能是身处排序强校的缘故吧)

代码
#include<bits/stdc++.h>
using namespace std;
int a[105],maxn,n,m;
void in(){scanf("%d%d",&n,&m);for(int i=1;i<=n;++i)scanf("%d",&a[i]);}
void ac()
{
	sort(a+1,a+1+n);maxn=a[n]+m;
	for(int i=1;i<=n;++i)m-=a[n]-a[i];
	if(m<0)printf("%d",a[n]);
	else printf("%d",a[n]+m/n+(bool)(m%n));
	printf(" %d",maxn);
}
int main(){in();ac();}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ShadyPi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值