10904 - Building designing 2 Status | Limits Submit Description An architect wants to design a very high building. The building will consist of some floors, and each floor has a certain size. The size of a floor must be greater than the size of the floor immediately above it and the size of the adjacent floor is either odd or even . In addition, the designer (who is a fan of a famous Spanish football team) wants to paint the building in blue and red, each floor a colour, and in such a way that the colours of two consecutive floors are different. To design the building the architect has n available floors, with their associated sizes and colours. All the available floors are of different sizes. The architect wants to design the highest possible building with these restrictions, using the available floors. Hints : Implement the compare function and modify the design function to get the highest possible building . function.c #include #include "function.h" #define RED 0 #define BLUE 1 int compare(const void *a, const void *b) { // Your code } // Modify the design function int design(int floorNum, Floor floorArr[]) { int height, color; int idx; qsort(floorArr, floorNum, sizeof(Floor), compare); height = 0; color = (floorArr[0].color == 'B') ? BLUE : RED; for (idx = 0; idx < floorNum; idx++) { if (color == BLUE && floorArr[idx].color == 'B') { height++; color = RED; } else if (color == RED && floorArr[idx].color == 'R') { height++; color = BLUE; } } return height; } function.h #ifndef FUNCTION_H #define FUNCTION_H typedef struct { char color; unsigned int size; } Floor; int compare(const void *a, const void *b); int design(int floorNum, Floor floorArr[]); #endif main.c #include #include #include #include "function.h" #define MAX_FLOOR_NUM 20000 int main() { int floorNum; int i; Floor floorArr[MAX_FLOOR_NUM]; scanf("%d", &floorNum); for (i = 0; i < floorNum; i++) { scanf(" %c %d", &floorArr[i].color, &floorArr[i].size); } printf("%d", design(floorNum, floorArr)); return 0; } Input The first line contains the number of available floors. Then, the size and color of each floor appear in one line. Each floor is represented with a character and an integer between 0 and 999999. There is no floor with size 0. Character 'B' represents the blue floor and character 'R' represents the red floor. The integer represents the size of the floor. There are not two floors with the same size. The maximum number of floors for a problem is 20000 Output The output will consist of a line with the number of floors of the highest building with the mentioned conditions. Note: The first floor must be the biggest size in the available floors. Sample Input Download 8 B 11 R 9 B 2 B 5 B 18 B 17 R 15 B 4 Sample Output Download 3