This is not a programming question. It's about finding an algorithm that gives you a correct result. Additionally it may be about finding an algorithm that gives you the result quickly, but you didn't say that. Either way, you might get more responses if you just remove the language tags.

The trick about finding (and evaluating) algorithms is finding *some* way that works, and then check whether it works in corner cases, or if there's something you can do to accelerate it, in case it's too slow.

The easiest approach to pretty much any problem with a limited number of potential solutions is called "brute force". Brute force means, you try every possible combination, and find out which one works.

In this case, the only problem is, what are the combinations, and how can I make sure I am trying them all? So let's look at the task: You have m jobs, and n people who could work on either of these jobs. That's a typical scheduling task. You can express this task as a list of assignments of jobs to people, e. g. {job 1, person 1}, {job 2, person3}, job 3, person 1}, {job 4, person 4}. Since every job is listed exactly once, and the order is not of importance, you can list this just as the list of persons instead, where the job number is implied by the position in the list. For the example above, that would be { 1, 3, 1, 4 }.

Going by that notation, if you want to express all schedules, you will need scheduling lists like this with the following conditions:

1. each list position corresponds to one of the m jobs, so the list has m elements.

2. each of the m elements corresponds to the number of one of the n people who will process the job at this position, so it can be any number from 1 through n

This means you need to set up a container for lists of m numbers, then generate all combinations of such lists by iterating each element from 1 to n, and add that combination to your container.

When you have that container, you have to find the best one, i. e. the one that results in the shortest processing time. For that you need a function that calculates the processing time for a given schedule. It shouldn't be hard to write that function.

For the example given, you'll get 5*5*5*5=625 schedules. For larger examples, the total number of schedules may be too large to store, so, instead of storing them in a container, you should just generate one schedule at a time, evaluate the processing time, and store that schedule only if it's among the best ones.

Moreover, for larger examples evaluating each and every schedule will be too time consuming: you should think of ways to reduce the number of schedules to test. But I won't delve into this here - for now it's only important for you to understand how to find 'a' solution, even if it's not the best one.

15,609,550 members

I think its ends with matrice to solve.