World Languages, asked by janu8686, 5 hours ago

You have N gems where each of the N gems have a value G You decide to ship M
boxes of these gems.
The boxes have infinite capacity so you can put any number of gems you want in a box
However, there is a problem, cach box has a value X associated with them. The value>
denotes the maximum allowed difference between the highest and lowest value of the
gems that can be kept in them.
For example: Let X be equal to 3, then you can keep gems of values 1.4 together in
box but you cannot put values 2,6 together.
Your task is to find the maximum number of boxes you can ship if you pack the gems
optimally.​

Answers

Answered by brainly0055
0

Answer:

There are many problems in online coding contests which involve finding a minimum-cost path in a grid, finding the number of ways to reach a particular position from a given starting point in a 2-D grid and so on. This post attempts to look at the dynamic programming approach to solve those problems. The problems which will be discussed here are :

Finding the Minimum Cost Path in a Grid when a Cost Matrix is given.

Finding the number of ways to reach from a starting position to an ending position travelling in specified directions only.

Finding the number of ways to reach a particular position in a grid from a starting position (given some cells which are blocked)

2. Finding Minimum-Cost Path in a 2-D Matrix

Problem Statement : Given a cost matrix Cost[][] where Cost[i][j] denotes the Cost of visiting cell with coordinates (i,j), find a min-cost path to reach a cell (x,y) from cell (0,0) under the condition that you can only travel one step right or one step down. (We assume that all costs are positive integers)

Similar questions