you task deliver box storage port ship however ship limit number box total weight carryyou give array box boxesi portsi weighti integer portscount maxBoxes maxWeightportsi port need deliver ith box weightsi weight ith boxportscount number portsmaxboxe maxWeight respective box weight limit shipthe box need deliver order give the ship follow stepsthe ship number box box queue violating maxboxe maxWeight constraintsFor load box order ship trip port box need deliver deliver if ship correct port trip need box immediately deliveredthe ship make return trip storage box queuethe ship end storage box deliveredreturn minimum number trip ship need deliver box respective port Example 1input box 112111 portscount 2 maxboxe 3 maxweight 3output 4explanation the optimal strategy follow the ship take box queue go port 1 port 2 port 1 return storage 4 tripsso total number trip 4note box deliver box need deliver order ie second box need deliver port 2 boxexample 2input box 1233313124 portscount 3 maxboxe 3 maxweight 6output 6explanation the optimal strategy follow the ship take box go port 1 return storage 2 trip the ship take second fourth box go port 3 return storage 2 trip the ship take fifth box go port 3 return storage 2 tripsso total number trip 2 2 2 6example 3input box 141221213234 portscount 3 maxboxe 6 maxweight 7output 6explanation the optimal strategy follow the ship take second box go port 1 return storage 2 trip the ship take fourth box go port 2 return storage 2 trip the ship take fifth sixth box go port 3 return storage 2 tripsso total number trip 2 2 2 6 Constraints1 boxeslength 1051 portscount maxboxe maxweight 1051 portsi portscount1 weightsi maxweight