#C10017. Sort Widgets Filtering
Sort Widgets Filtering
Sort Widgets Filtering
You are given an integer N and a list of N integers representing the sizes of widgets. In this list, a widget with size -1
is considered faulty and should be ignored. Your task is to filter out the faulty widgets and print the remaining widget sizes sorted in non‐ascending order (from largest to smallest).
Note: The sorting order is defined as \(a_1 \ge a_2 \ge \cdots \ge a_k\) where \(a_i\) are the valid widget sizes.
inputFormat
The input is read from stdin
and consists of:
- An integer
N
representing the number of widgets. - A line with
N
space-separated integers indicating the sizes of the widgets. A value of-1
indicates a faulty widget.
outputFormat
Output the valid widget sizes in non-ascending order (largest to smallest) as a sequence of space-separated integers to stdout
. If there are no valid widgets, output an empty line.
5
2 3 -1 6 4
6 4 3 2