Kalpana Chawla is planning an expedition to Jupiter for π people. One of the important tasks is to provide biscuits for each participant.
The warehouse has π daily biscuit packages. Each package has some biscuits type ππ.
Each participant must eat exactly one biscuit package each day. Due to extreme loads, each participant must eat the same biscuit type throughout the expedition. Different participants may eat different (or the same) types of biscuits.
Formally, for each participant π Kalpana Chawla should select the biscuit type ππ and each day π-th participant will eat one biscuit package of type ππ. The values ππ for different participants may be different.
Input:
The first line contains two integers π and π β the number of the expedition participants and the number of the daily biscuit packages available.
The second line contains a sequence of integers π1,π2,β¦,ππ, where ππ is the type of π-th biscuit package.
Output:
Print the output, the number of days the expedition can last. If it is not possible to plan the expedition for even one day, print 0
#include<stdio.h> #include<stdlib.h> int cmpfunc(const void *a,const void *b){ return(*(int*)b-*(int*)a); } int main() { int a[101]={0},n,m,num,ans=0,i,day; scanf("%d %d",&n,&m); for(i=0;i<m;i++){ scanf("%d",&num); a[num]++; } qsort(a,101,sizeof(int),cmpfunc); for( day=1;day<=100;day++){ num=0; for(i=0;a[i]!=0;i++){ num+=(a[i]/day); } if(num>=n) ans=day; } printf("%d",ans); return 0; }
INPUT_1:
4 8
2 1 1 1 2 5 7 2
OUTPUT:
1
INPUT_2:
2 5
5 4 3 2 1
OUTPUT:
1
ILLUSTRATION
Morae Q!
- Find the length of the array’s longest increasing sub-sequence.
- Arrange numbers in a circle so that any two neighbouring numbers differ by 1.
- Find partial names and count the total numbers.
- Find the minimized sum of non-deleted elements of the array after the end of the game.
- Find the maximum number of good sleeping times optimally.
- Sort the elements of the array in the order in which they are required.
- Find the minimum number of flats, monkey needs to visit to catch ninjas.
- Convert the square matrix to matrix in Z form.
- Shift the K elements of each row to right of the matrix.
- Find maximum possible number of students in a balanced team with skills.
- Find the Maximum number of pairs of points you can match with each other.
- Calculate the number of non-empty good subarrays of given array.
- Transform the binary string A into the string B using finite operations.
- Find the number of potion must the character take to jump the hurdles.
- Count the total number of vowels and consonants.
- Return all elements of the matrix in spiral order.
- Return all palindromic paths of the matrix.
- Write the code to change the display in reverse order using pointer.
- Find the number of days the expedition can last.
- Find the minimum size of the sub-segment to make the array pairwise distinct.