#K2066. Filtering Items by Criteria
Filtering Items by Criteria
Filtering Items by Criteria
You are given a list of items and a filtering criterion. Your task is to output only those items that satisfy the criterion. There are two modes:
- Integer Mode: When the type indicator is 1, the items are integers. An item is kept if it is strictly greater than a specified threshold. Formally, an integer item x is kept if \( x > k \), where \( k \) is the threshold.
- String Mode: When the type indicator is 2, the items are strings. An item is kept if it contains a given substring (case-sensitive).
The filtered items should be printed in their original order, separated by a single space. If no items satisfy the criterion, output an empty line.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer that indicates the type of items:
1
for integers and2
for strings. - The second line contains the filtering criterion. For integer mode, this is an integer threshold \( k \); for string mode, this is a substring.
- The third line contains an integer \( n \) representing the number of items.
- The fourth line contains \( n \) items separated by spaces. In integer mode, these will be valid integers. In string mode, these will be non-empty strings.
outputFormat
Output a single line to standard output (stdout) containing the filtered items in their original order, separated by a single space. If no items satisfy the condition, output an empty line.
## sample1
3
5
1 2 3 4 5
4 5