#include #include int compare(const void *a, const void *b){ return *(int*)a - *(int*)b; } int main(){ int small[10001]; int amo; int big; int sum = 0; // printf("input size of bigbox :"); scanf("%d",&big); // printf("input the amount of smallboxes :"); scanf("%d",&amo); // printf("input size of smallboxes\n"); int i; for(i = 0; i < amo; i++){ printf("%d :",i+1); scanf("%d",&small[i]); } qsort(small, amo, sizeof(int), compare); int j = 0; while(j < amo && sum < big ){ sum += small[j++]; } printf("%d\n",j-1); return 0; }