https://www.acmicpc.net/problem/2805
#include<stdio.h>
int main() {
int n,m;
scanf("%d %d",&n,&m);
int arr[n];
for(int i=0;i<n;i++){
scanf("%d",&arr[i]);
}
long max=1000000000;
long min=1;
long mid=0;
while(min<=max){
long num=0;
mid=(min+max)/2;
for(int i=0;i<n;i++){
if(arr[i]>=mid) num+=arr[i]-mid;
}
if(num>=m) min=mid+1;
else max=mid-1;
}
printf("%d",max);
}