| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10904 | Building designing 2 |
|
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 what's more, the sum of any two adjacent floor sizes is odd. 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 color, and in such a way that the colors of two consecutive floors are different.
To design the building the architect has n available floors, with their associated sizes and colors. 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 <stdlib.h> #define RED 0 int compare(const void *a, const void *b) { } // Modify the design function qsort(floorArr, floorNum, sizeof(Floor), compare); height = 0; for (idx = 0; idx < floorNum; idx++) { |
function.h
|
#ifndef FUNCTION_H typedef struct { int compare(const void *a, const void *b); int design(int floorNum, Floor floorArr[]); #endif |
main.c
|
#include <stdio.h> #include <stdlib.h> #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.