PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
There are R red gems which can be sold for P coins each, and B blue gems which can be sold for Q coins each.
You take take either red gems or blue gems, but not both. How many coins can you earn at best?
EXPLANATION:
Taking all R red gems and selling each for P coins will give a total of R\cdot P coins.
Taking all B red gems and selling each for Q coins will give a total of B\cdot Q coins.
We can only do one or the other, so the answer is
\max(R\cdot P, B\cdot Q)
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
r, b, p, q = map(int, input().split())
print(max(r*p, b*q))