Cod sursa(job #105066)

Utilizator DastasIonescu Vlad Dastas Data 16 noiembrie 2007 23:36:48
Problema Grupuri Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <cstdio>

const int maxn = 100001;

FILE *in = fopen("grupuri.in","r"), *out = fopen("grupuri.out","w");

int k, n;
int a[maxn];

int max;
long long s;
void read()
{
    fscanf(in, "%d %d", &k, &n);

    for ( int i = 1; i <= n; ++i )
        fscanf(in, "%d", &a[i]), s += a[i];

    max = a[n];
}

int main()
{
    read();

    if ( max <= s / k )
        fprintf(out, "%d\n", s / k);
    else
    {
        while ( max > s / k )
            s -= a[n--], --k, max = a[n];

        fprintf(out, "%d\n", s / k);
    }


	return 0;
}