Cassette P65849


Statement
 

pdf   zip

You have a cassette with tt seconds of length, and nn songs with lengths d1,d2,,dnd_1, d_2, \dots, 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 tt and nn. The second one has nn numbers: d1,d2,,dnd_1, d_2, \dots, d_n. You can assume 1t1081 \le t \le 10^8, n1n \ge 1, and that for each ii, 1di1061 \le d_i \le 10^6.

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 n100n \le 100 will be fulfilled.

  • TestB:   Other test cases will include cases with n105n \le 10^5.

Public test cases
  • Input

    11 5
    2 2 2 2 2
    
    10 5
    2 2 2 2 2
    
    100 1
    101
    
    1000 3
    17 1 17
    

    Output

    4
    3
    0
    3
    
  • Information
    Author
    Omer Giménez
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++