TWODISH - Editorial

PROBLEM LINK:

Contest - Division 3
Contest - Division 2
Contest - Division 1

DIFFICULTY:

CAKEWALK

PROBLEM:

You have A fruits, B vegetables and C fishes. You can make a single meal using 1 fruit and 1 vegetable or using 1 vegetable and 1 fish.
Determine if you can make at least N meals.

EXPLANATION:

The number of meals that can be prepared can not exceed B, since each meal requires 1 vegetable (and there are only B vegetables).

Also, the number of meals can not exceed A+C, since each meal also requires either a fruit or a fish (and there are a total of A+C fruits and fishes).

Therefore, the number of meals that can be prepared is clearly the lower of the two constraints \implies \min (B, A+C).
Then, output YES if the value is \ge N and NO otherwise.

TIME COMPLEXITY:

O(1)

per test case.

SOLUTIONS:

Editorialist’s solution can be found here.


Experimental: For evaluation purposes, please rate the editorial (1 being poor and 5 excellent)

  • 1
  • 2
  • 3
  • 4
  • 5

0 voters

CodeChef | Competitive Programming | Participate & Learn | CodeChef
can you tell where my solution give wrong answer…