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:
Chef has A silver coins and B gold coins.
He can sell a silver coin for 1 rupee, and convert a gold coin to two silver coins.
How much money can he earn in total?
EXPLANATION:
Each silver coin can be sold for 1 rupee, so A silver coins will result in A rupees.
Each gold coins can be converted into two silver coins, which sell for two rupees each. So, each gold coin is effectively worth 2 rupees; hence with B of them that’s 2B rupees overall.
Thus, the total money Chef can earn is
A + 2B
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
a, b = map(int, input().split())
print(a + 2*b)