Some guns are placed in a line. The guns are sorted by their type. You will get N consecutive guns for your regiment and, of course, you want to maximize the sum of your guns' powers.
You will be given ints counts and powers. counts[i] is the number of guns of type i, and powers[i] is the power of each gun of type i. Guns are given in the same order that they are in the line. Return the maximal sum of gun power that you can get.
|Parameters:||int, int, int|
|Method signature:||int chooseGuns(int counts, int powers, int N)|
|(be sure your method is public)|
|-||counts will have between 1 and 50 elements, inclusive. |
|-||powers will have between 1 and 50 elements, inclusive. |
|-||counts and powers will have the same number of elements.|
|-||Each element of counts will be between 1 and 1000000, inclusive. |
|-||Each element of powers will be between 1 and 1000, inclusive. |
|-||N will be between 1 and 1000000, inclusive. |
|-||N will be between 1 and the sum of elements in counts, inclusive. |
|We can take 5 guns with power 7 and 15 guns with power 2.|
|We can take 4 guns with power 8 and 16 guns with power 4.|
|We can take all the guns.|