#C7936. Sum of Two Smallest Positive Numbers
Sum of Two Smallest Positive Numbers
Sum of Two Smallest Positive Numbers
Given a list of integers, your task is to find the sum of the two smallest positive numbers. If there are fewer than two positive numbers, output None.
Mathematically, if the list of positive numbers is \(P = \{p_1, p_2, \dots, p_k\}\) with \(p_1 \le p_2 \le \dots \le p_k\), the answer is computed as:
\(\text{answer} = \begin{cases} p_1 + p_2, & \text{if } k \ge 2 \\ \text{None}, & \text{otherwise} \end{cases}\)
For example, if the input is 19 5 42 2 77
, the two smallest positive numbers are 2 and 5, so the output is 7.
inputFormat
The input is provided as a single line on standard input containing space-separated integers.
outputFormat
Output a single line on standard output: the sum of the two smallest positive numbers, or None
if there are fewer than two positive numbers.
19 5 42 2 77
7