REC19A question,need help about solution

can you please help me with my query regarding the problem mentioned below

I tried the problem set for REC19 ,and coded for the solution as follows:!

Despite the output is correct as per me,but it is being shown as wrong output.
can you please guide me with correct solution.please
Thanking you

What should the answer be for the testcase:

3 6
1 2 3


1 Like

“NO” ?
I think ,cause its not in range of values we have

What isn’t? :slight_smile:

1 Like

Currently, he has N cheese with distinct calorie value a1,a2,…,ana1,a2,…,an. Jerry wants his total calorie intake to be K. To achieve his calorie diet, he can steal at most 1 cheese such that:

  • its calorie value should lie between the minimum and maximum calorie value of cheese he already has
  • its calorie value should not coincide with any available cheese calorie value
    Then as per your inputs if we input 3 as N means we have 3 cheese available and K=6 means calories required =6
    since value of calories previously available are 1,2 and 3 then then as per 1st point he can’t have further calories,
    this is what I understood of the question

can you please let me know of the right answer to help me develop?

I think since Jerry has already eaten K (here k = 6) calories, thus the answer should be yes in this case.


Thank You Bhaiya,
also can you suggest me how I can get stars as I am new to this site as well as competitive coding

I too have a lot to learn here, but as a start i would suggest you not to go for the stars but rather to practice and attempt questions regularly.Also, take part in short contests as well since they improve your thinking under time pressure.