Cod sursa(job #641653)

Utilizator Smaug-Andrei C. Smaug- Data 29 noiembrie 2011 00:11:59
Problema Grupuri Scor 36
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
//----------------------------------------------------
// 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);

}