Cassette

You have a cassette with t seconds of length, and n songs with lengths
d₁, d₂, …, d_(n). Your aim is to store the maximal number of whole songs
in the cassette. You must consider that songs must be recorded with a
second of separation between them.

Input

The input consists of a series of cases separated with a line in white.
Each case consists of two lines: The first one has t and n. The second
one has n numbers: d₁, d₂, …, d_(n). You can assume 1 ≤ t ≤ 10⁸, n ≥ 1,
and that for each i, 1 ≤ d_(i) ≤ 10⁶.

Output

For each case of the input, your program must print the maximal number
of whole songs that fit in the cassette, bearing that they must be
separated by a second in mind.

- TestA:   In some test cases n ≤ 100 will be fulfilled.

- TestB:   Other test cases will include cases with n ≤ 10⁵.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:26:21.105Z

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