#include <stdio.h> #include "malloc.h" //#include <mm_malloc.h> #include <stdlib.h> int *needPaint; int *leftPaint; int colorType; int graySize; int cmp(const void *p,const void *q) { return *(int*)p<*(int*)q?1:-1; } int kitN(){ int k; int j; int currentKit = 0; qsort(needPaint,colorType ,sizeof(int),cmp); if(needPaint[0]%50==0) currentKit =needPaint[0]/50; else currentKit = needPaint[0]/50+1; for(j=0;j<colorType;j++){ leftPaint[j] = currentKit*50-needPaint[j]; } while(graySize>0){ qsort(leftPaint,colorType ,sizeof(int),cmp); if(leftPaint[2]==0){ currentKit++; for(k=0;k<colorType;k++){ leftPaint[k] += 50; } graySize--; }else{ graySize--; leftPaint[0]--; leftPaint[1]--; leftPaint[2]--; qsort(leftPaint,colorType ,sizeof(int),cmp); } } return currentKit; } int main() { while(scanf("%d",&colorType) && colorType){ int i; needPaint = (int*)malloc(sizeof(int)*(colorType)); leftPaint =(int*)malloc(sizeof(int)*(colorType)); for(i=0;i<colorType;i++){ scanf("%d",&needPaint[i]); } scanf("%d",&graySize); printf("%d ",kitN()); } return 0; }