Pagini recente » Monitorul de evaluare | Cod sursa (job #105066)
Cod sursa(job #105066)
#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;
}