Pagini recente » Cod sursa (job #672746) | Cod sursa (job #1238316) | Cod sursa (job #1512305) | Cod sursa (job #684006) | Cod sursa (job #641650)
Cod sursa(job #641650)
//----------------------------------------------------
// 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 1000010
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[i]; N--; K--;
}
printf("%lld", sum/K);
}