Given N medicine bottles and M containers and each container has capacity to carry W[i] bottles.
The delivery van can take two containers (only one can also be loaded) to nearby hospital in single trip. Containers can be reused.
Find number of trips to deliver minimum N bottles. If not possible, print -1
Contraints
1 <= N,M,W[i] <= 1000
W.length == M
N = 5, M = 2
W[] = {1, 3}
Output = 2
N = 6, M = 2
W[] = {4, 5}
Output = -1
N = 720, M = 5
W[] = {27, 52, 119, 144, 124}
Output = 5
I tried using 2d/3d DP but got TLE.