Let us assume that this question comes in the exam then I suppose we could try putting a couple of random values into 'm' and 'n' and then make an educated guess here.
Case 1: m = 3, n =5
Now since sum of max needs is less than 'm+n' therefore,
Sum of max needs < 8
There are 3 processes so lets distribute the resources randomly:
5 + 1 + 1 < 8
Now allocating (max-1) resource to each of the above processes we get,
5[4] + 1[0] + 1[0] < 8 ........................Still left with the 5th resource which could be allotted to any of the 3 processes and won't let the deadlock happen.
Case 2: m = 7, n = 8
Sum of max needs < 15
After distribution we get:
5 + 2 + 1 + 2 + 1 + 1 +2 < 15
Allocating (max - 1) resource to each of the above process,
5[4] + 2[1] + 1[0] + 2[1] + 1[0] + 1[0] + 2[1] < 15 ............................Still left with the 8th resource which would never let a deadlock happen.
.
.
.
P.S. : Try yourself for a case where n < m.