Problems
10017 - Gift
SUBMIT PROBLEM

Gift

Time Limit: 1 sec

 

The Problem

I will meet 5 of my friends tomorrow. For that I want to gift them the same thing for each within my total budget, which is 600 tk.

The shopkeeper confuses me by showing 4 different attractive items in different price. I always want to buy expensive things for my friends within my budget.

 

Can you please help me which one should I buy for them? 

 

The Input

There are several lines of input in the input file, and each line contains six positive integer numbers first one is my budget (500<T<1000000) second one is number of friend (0<N<100) and last four denotes the price of four gift P1, P2, P3 and P4 .All prices are not greater than 10000. Input is terminated by EOF

 

The Output

For each line of input, you have to print the price of the gift which I should buy for my friends.

 

Sample Input

600 5 95 100 115 125

1000 10 70 100 110 60 

 

Sample Output

115

100

 

 

 

[College Level]

Inter School & College Programming Contest (ISCPC) 2015 

Problem Setter: Debraj Barua