#include #include #include #include #include #include #include int main(){ int n; scanf("%d",&n); int *types = malloc(sizeof(int) * n); for(int types_i = 0; types_i < n; types_i++){ scanf("%d",&types[types_i]); } //5 <= n <= 2 * pow(10, 5); //type ID is always 1,2,3,4, or 5; //if equal for 2 different types, print out type with lowest ID; //from the above given code, n = number of birds and types = array with types of birds //array where index corresponds to type ID, and value at index is a count of the type ID. //Use size = 6 b/c indices used are 1,2,3,4,5. So index 0 will always be 0 int type_count[6] = {0}; //iterate through types and increment the bird type ID count for(int i = 0; i < n; ++i){ ++type_count[types[i]]; } int max = type_count[0]; int result_type = 0; //find (first) largest count for(int i = 1; i < 6; ++i){ if(type_count[i] > max){ max = type_count[i]; result_type = i; } } printf("%d", result_type); return 0; }