EXGS - Editorial

PROBLEM LINK:

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

Author: iceknight1093
Tester: raysh07
Editorialist: iceknight1093

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

X guests were expected at a party, but Y arrived in the end (X \lt Y).
X plates of food were already ordered, costing 100 rupees each.
Every extra plate of food costs 150 rupees instead.
What’s the total cost of feeding everyone?

EXPLANATION:

X plates at 100 rupees each comes out to be a total cost of 100\cdot X.

Since X \lt Y, there are (Y - X) extra people.
Each of them needs one plate of food, costing 150.
This has a cost of 150\cdot (Y-X).

The total cost is obtained by adding up these two numbers, to obtain

100\cdot X + 150\cdot (Y-X)

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
x, y = map(int, input().split())
print(100*x + 150*(y-x))