#K41082. Affordable Snacks
Affordable Snacks
Affordable Snacks
Given a list of snack names and their corresponding prices, along with the available balance, determine which snacks can be purchased. A snack is considered affordable if its price is less than or equal to the available balance. In other words, for each snack \(i\) with price \(p_i\), it can be bought if \(p_i \leq B\), where \(B\) is the balance.
Your task is to output the names of the affordable snacks in the order they are given. If no snack meets the criteria, output an empty line.
inputFormat
The input is provided via stdin in the following format:
- An integer \(n\) representing the number of snacks.
- A single line containing \(n\) snack names separated by spaces.
- A single line containing \(n\) integers representing the prices of the snacks.
- An integer representing the available balance \(B\).
outputFormat
Output the names of the snacks that can be afforded, in the order they appear in the input, separated by a single space. If no snack is affordable, print an empty line.
## sample4
chips chocolate cookies soda
50 100 70 30
150
chips chocolate cookies soda
</p>