SUBCOST7 - Editorial

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:

A subscription service costs X per month for the first 3 months and then Y per month after that.
What’s the total cost for N months?

EXPLANATION:

If N \le 3 then every month has a cost of X, so the answer is simply N\cdot X.

If N \gt 3 then the first 3 months have a cost of X each, while the remaining (N-3) months have a cost of Y.
The answer is hence

3\cdot X + (N-3)\cdot Y

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
for _ in range(int(input())):
    n, x, y = map(int, input().split())
    
    if n <= 3: print(n*x)
    else: print(3*x + (n-3)*y)

I wrote the same too… I hope i dont get plagarised