#include <cstdio>
#include <algorithm>
using namespace std;
int h[1000005]={};
int main()
{
int n,m;
scanf("%d %d",&n,&m);
int mth=0;
for(int i=0; i<n; i++)
{
scanf("%d",&h[i]);
if(mth<h[i])
mth=h[i];
}
int mch=0;
for(int i=1; i<mth; i++)
{
long long cts=0;
for(int j=0; j<n; j++)
{
if(h[j]>i)
cts+=h[j]-i;
}
if(cts<m)
break;
mch=i;
}
printf("%d",mch);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: