Small sums

A certain value v is given to you, as well as some different numbers.
Your program must compute how many of the given numbers can be added up
with other two given numbers, so that the sum is not greater than v. You
can suppose that there are, at least, three numbers.

For instance, if v is 15 and the given numbers are 12, 2, 5, 14 and 1,
there only is a number (14) that cannot be added up with other two
numbers without exceeding 15. All the other numbers can be added up. For
instance, 2 can be added up with 5 and 1, giving as a result 8, that is
less or equal than 15.

Input

The input consists of a line with an integer v, followed by a line with
a number n between 3 and 10000, followed by a line with n different
numbers.

Output

Your program must print a line with the quantity of the fiven numbers
that can be added up with other two of these numbers so that the result
is not greater than v.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:17:06.495Z

© Jutge.org, 2006–2026.
https://jutge.org
