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 1010people will occupy it.

题意:题目大意:公园里有n个座位,一开始每个座位都有多少人(人数给出),公园里将进来m人,问这些人往座位上坐,那么座位上人数最多的那个能有多少人,最多人数最小化能有多少人? 

思路:最大的肯定好求,最小的要分两类讨论;

我的做法是,把所有的人数都加起来,然后除以凳子数,相当于把人数平均分到每个凳子上,如果%n有剩下的就+1,就是所求;

问题来了,可能后来来的人数比较少,导致不满足这种分法时,开始时的最大值就是最多人数最小化的值,只要两者比较大小取大者就行

啦~啦~啦~~~

还在比赛呢,我怎么跑来打CF啦~~~

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    int a[101];
    cin>>n>>m;
    int ans=0;
    int sum=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        ans+=a[i];
        sum=max(sum,a[i]);
    }
    int t=sum;
    sum+=m;
    ans+=m;
    int l=ans%n;
    ans=ans/n;
    if(l)
        ans+=1;
    ans=max(ans,t);
    printf("%d %d\n",ans,sum);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/chen_zan_yu_/article/details/82939747