Article From:https://www.cnblogs.com/ErkkiErkko/p/9686854.html

> code:

#include <iostream>
#include <cstdio>
#include <cstdlib>

const int MAXN=105;
int n,m,a[MAXN],maxa,suma;

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        maxa=std::max(maxa,a[i]);
        suma+=a[i];
    }
    suma+=m;
    int temp=maxa*n;
    if(temp>=suma) printf("%d ",maxa);
    else printf("%d ",maxa+(suma-temp-1)/n+1);
    printf("%d\n",maxa+m);
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *