Bee
Practice
5 (1 votes)
Problem
33% Success 418 Attempts 20 Points 3s Time Limit 256MB Memory 1024 KB Max Code

There is a bee which consumes \(N\) units of nectar to give birth to offsprings. There are \(K\) flowers present in a garden and the amount of nectar available in each flower is given in an array \(a\), where \(a[i]\) is the nectar available in flower \(i\). You have to find the number of the day on which the bee reproduces. If a bee gets the desired amount of nectar on \(i^{th}\) day, then it reproduces on that day itself else it continues to consume nectar coming days until it gets the desired amount. Each flower is renewed with the nectar every day(the nectar for \(i^{th}\) flower remains the same for all days).

Input

The first line contains two space separated Integers \(N\) and \(K\) denoting desired units of nectar and number of flowers respectively.

The second line contains \(K\) space separated integers i.e. elements of array \(a\) where \(a[i]\) denotes the amount of nectar available in flower \(i\).

Constraints

  • \(1 \leq N \leq 10^{18}\)
  • \(1 \leq K \leq 10^5\)
  • \(1 \leq a[i] \leq 10^5\)

Output

Print an integer denoting the number of day on which the Bee produces offsprings.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
1 votes
Points:20
11 votes
Tags:
Easy
Points:20
Tags:
ImplementationEasyMath