Pagini recente » Cod sursa (job #1963436) | Cod sursa (job #2224894) | Cod sursa (job #2531864) | Cod sursa (job #2600148) | Cod sursa (job #641653)
Cod sursa(job #641653)
//----------------------------------------------------
// Discard the "colums" that are occupied by only one
// type of animal. The sum of the remaining animals
// divided by the size of the groups gives the answer.
//----------------------------------------------------
#include <cstdio>
#define MAXN 100010
int main(){
freopen("grupuri.in", "r", stdin);
freopen("grupuri.out", "w", stdout);
int K, N, i;
static int A[MAXN];
long long sum = 0;
scanf("%d%d", &K, &N);
for(i=0; i<N; i++){
scanf("%d", A+i);
sum+=A[i];
}
while(sum/K < A[N]){
sum-=A[N]; N--; K--;
}
printf("%lld", sum/K);
}