
isPossibleTeam
Bob is a football coach where he has n
students, he told Tom that the minimum height between his students is equal to a
, and the maximum height between his students is equal to b
, and the sum of heights of his students is equal to s
.
Tom thinks that the description that Bob gave him is wrong, and it is impossible to have such students with that description.
Tom is not sure about that, so he asked you for help.
Given 4 integer numbers n,a,b,s
you should tell him if Bob’s description is wrong for sure, or if it is possible to have students with that description.
Example:
- For
n = 5 , a = 2, b = 4, s = 13
. The output should beisPossibleTeam(a) = true.
Because:
Bob has5
students, minimum height between5
students is2
, maximum height between5
students is 4 and sum of height of these students equals to13
.
The heights of these students are :2 2 2 3 4
. - For
n = 5, a = 2,b = 3, s = 30
. The output should beisPossibleTeam(a) = false.
Because:
There is no such team with that description.
Input/Output
- [Execution time limit] 0.5s (C++), 3s (Java and C#), 4s (Python, GO và JS)
- [input] int n
The number of students.1 ≤ n ≤ 100
- [input] int a
The minimum height between students1 ≤ a ≤ 250
- [input] int b
The maximum height between students1 ≤ a ≤ b ≤ 250
- [input] int s
The sum of heights of students.1 ≤ s ≤ 25000
[output] boolean
Returntrue
if Bob’s description is true, otherwise returnfalse
.
Post Comment