Masala #TWLR5VLFUQ
Sharchalar
Imonada N ta ko'k sharcha bor. U sharchalar bilan 2 xil usulda savdo qila oladi: K ta ko'k sharchani M ta qizil sharchaga yoki P ta qizil sharchani L ta yashil sharchaga almashtirishi mumkin. U eng ko`pi bilan nechta yashil sharchani qo'lga kirita olishini hisoblovchi dastur tuzing.
Birinchi qatorda N sharchalar soni beriladi. \((1≤N≤10^6)\)
Ikkinchi qatorda K,M,P,L lar beriladi. \((1≤K,M,P,L≤10^6)\)
Masala javobini chop eting.
# | input.txt | output.txt |
---|---|---|
1 |
45 10 3 2 3 |
18 |
2 |
52 14 3 5 8 |
8 |