Loading Now

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 be isPossibleTeam(a) = true.
    Because:
    Bob has 5 students, minimum height between 5 students is 2, maximum height between 5 students is 4 and sum of height of these students equals to 13
    The heights of these students are : 2 2 2 3 4
  • For n = 5, a = 2,b = 3, s = 30. The output should be isPossibleTeam(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 students
    1 ≤ a ≤ 250
  • [input] int b
    The maximum height between students
    1 ≤ a ≤ b ≤ 250
  • [input] int s
    The sum of heights of students.
    1 ≤ s ≤ 25000
  • [output] boolean
    Return true if Bob’s description is true, otherwise return false.

Post Comment

Contact