TASTEDEC - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author & Editorialist: Nishank Suresh
Testers: Takuki Kurokawa, Utkarsh Gupta

DIFFICULTY:

324

PREREQUISITES:

None

PROBLEM:

One bar of chocolate has a tastiness of X, and one piece of candy has a tastiness of Y.
Is it better to buy 2 bars of chocolate or 5 pieces of candy?

EXPLANATION:

Two bars of chocolate have a total tastiness of 2X.
Five pieces of candy have a total tastiness of 5Y.

So

  • The answer is ‘chocolate’ if 2X \gt 5Y.
  • The answer is ‘candy’ if 2X \lt 5Y.
  • The answer is ‘either’ if 2X = 5Y.

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Code (Python)
for _ in range(int(input())):
	x, y = map(int, input().split())
	if 2*x > 5*y:
		print('Chocolate')
	if 2*x < 5*y:
		print('Candy')
	if 2*x == 5*y:
		print('Either')