题目:http://codeforces.com/problemset/problem/1042/A
代码如下:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mid ((l+r)>>1)
using namespace std;
int const maxn=;
int n,m,a[maxn],ans,mx;
bool ck(int x)
{
int ret=;
for(int i=;i<=n;i++)ret+=x-a[i];
return (ret>=m);
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)scanf("%d",&a[i]),mx=max(mx,a[i]);
int l=mx,r=mx+m;
while(l<=r)
{
if(ck(mid))ans=mid,r=mid-;
else l=mid+;
}
printf("%d %d\n",ans,mx+m);
return ;
}