#K51212. Unique Height Floor Building
Unique Height Floor Building
Unique Height Floor Building
In this problem, you are given a set of possible floors to build a structure. Each floor has a height and a cost. You need to select floors such that no two selected floors have the same height, and the total cost of the selected floors does not exceed a given budget (B). Your goal is to maximize the number of floors built with unique heights.
Formally, let (N) be the number of available floors. For the (i)-th floor, its height is (H_i) and cost is (C_i). You must choose a subset of indices (S) such that for any two indices (i, j \in S) with (i \neq j), (H_i \neq H_j), and (\sum_{i \in S} C_i \le B). The task is to maximize (|S|), the number of floors built.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer (N) representing the number of available floors.
- The second line contains (N) space-separated integers representing the heights (H_1, H_2, \dots, H_N).
- The third line contains (N) space-separated integers representing the costs (C_1, C_2, \dots, C_N).
- The fourth line contains an integer (B) representing the total budget.
outputFormat
The output is printed to standard output (stdout) and consists of a single integer denoting the maximum number of floors with unique heights that can be built without exceeding the budget.## sample
5
1 2 3 2 4
10 20 30 40 25
50
2